AEM 6.2 JSP Connection to a Postgres db | Community
Skip to main content
November 10, 2017
Solved

AEM 6.2 JSP Connection to a Postgres db

  • November 10, 2017
  • 1 reply
  • 894 views

I am trying to test a quick JSP connection to a postgres db. I was following a tutorial using the Felix Console and uploaded the org.postgresql.jdbc41 jar to the Day Commons JDBC Connections Pool. What I am having trouble figuring out is how exactly to use any of this to connect to the database.

I really just need to grab a simple array of values and need the simplest implementation to get this work.

<%@ page import = "java.sql.*" %>

<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %><%@ taglib prefix = "sql" uri="http://java.sun.com/jstl/sql" %>

<%

        Class.forName("org.postgresql.jdbc41");

        Connection con = DriverManager.getConnection("jdbc:postgresql:" + ip, username, pass);

%>

<%

       Statement statement = con.createStatement();

       ResultSet rs = stmt.executeQuery("select * from details");

       while (rs.next()) {  

%>

      <%= rs.getString("address") %>

<%

      }

%>

I understand that I'm doing this incorrectly, but I could really use some help figuring out what I'm doing wrong.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

See this Article - how to use a DataSourcePool to connect to a database -- Scott's Digital Community: Injecting a DataSourcePool Service into an Adobe Experience Manager OSGi bundle

1 reply

smacdonald2008
smacdonald2008Accepted solution
Level 10
November 10, 2017

See this Article - how to use a DataSourcePool to connect to a database -- Scott's Digital Community: Injecting a DataSourcePool Service into an Adobe Experience Manager OSGi bundle