【问题标题】:external database with Adobe CQ5?Adobe CQ5 的外部数据库?
【发布时间】:2011-07-12 13:08:47
【问题描述】:

有没有办法连接外部数据库,如mysql可以连接到Adobe CQ5

Adobe cq5中的JCR(Java Content Repository)现在默认连接到H2数据库...如何让它使用sql/mysql?

【问题讨论】:

    标签: mysql database adobe external aem


    【解决方案1】:

    转到:/system/console/configMgr
    打开:JDBC 连接池配置
    输入所有标准 JDBC 配置元素(用户名、密码、驱动程序、JDBC URI)
    输入数据源名称(以下称为 yourDataSourceName)

    在您的 JSP 或 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) { } 
    }

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多