external database with Adobe CQ5?

爷,独闯天下 提交于 2019-11-30 15:22:31

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) { } 
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!