Go to the section: / system / console / configMgr
Open: JDBC Connections Pool Configuration
Enter all the standard JDBC configuration items (username, password, driver, JDBC URI)
Enter the name of the data source (hereinafter referred to as your file name)
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) { } }
source share