external database with Adobe CQ5?

前端 未结 1 1246
广开言路
广开言路 2021-01-03 07:22

Is there any way to connect external data base like mysql can be connected to Adobe CQ5?

JCR(Java Content Repository) in Adobe cq5

相关标签:
1条回答
  • 2021-01-03 07:46

    Go to: /system/console/configMgr
    Open up: the JDBC Connections Pool configuration
    Enter all the standard JDBC config elements (username, password, driver, JDBC URI)
    Enter a Datasource Name (referred to below as yourDataSourceName)

    In your JSP or Servlet:

    <%@ page import="com.day.commons.datasource.poolservice.DataSourcePool" %>
    <%@ page import="javax.sql.DataSource" %>
    
    DataSourcePool dbService = sling.getService(DataSourcePool.class);
    DataSource ds = (DataSource) dbService.getDataSource("yourDataSourceName");
    
    if(ds != null) {
       try {
          %><sql:query var="result" sql="SELECT now()" dataSource="<%=ds%>" /><%
       } catch (Exception e) { } 
    }
    0 讨论(0)
提交回复
热议问题