-
-
Save dfparker2002/1401c446529746982451ab358596091c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@include file="/libs/foundation/global.jsp"%><% | |
%><%@page session="false" contentType="text/html; charset=utf-8" | |
pageEncoding="UTF-8" | |
import="org.apache.sling.api.resource.*, | |
com.day.commons.datasource.poolservice.DataSourcePool, | |
javax.sql.*, | |
java.sql.*, | |
java.util.*, | |
javax.jcr.*, | |
com.day.cq.search.*, | |
com.day.cq.wcm.api.*, | |
com.day.cq.dam.api.*"%><% | |
DataSourcePool dspService = sling.getService(DataSourcePool.class); | |
try { | |
DataSource ds = (DataSource) dspService.getDataSource("sqlite"); | |
if(ds != null) { | |
%><p>Obtained the datasource!</p><% | |
%><%final Connection connection = ds.getConnection(); | |
final Statement statement = connection.createStatement(); | |
final ResultSet resultSet = statement.executeQuery("SELECT * from assets"); | |
int r=0; | |
while(resultSet.next()){ | |
r=r+1; | |
} | |
resultSet.close(); | |
%><p>Number of results: <%=r%></p><% | |
} | |
}catch (Exception e) { | |
%><p>error! <%=e.getMessage()%></p><% | |
} | |
%> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment