Skip to Content
0
May 19, 2016 at 09:26 AM

Issues connecting to MaxDB using HCP

25 Views

Hi,

We have deployed a JAVA application in HCP in Java EE 6 Web Profile runtime. We are trying to create and read data from a MaxDB instance bound to the JAVA application(with default binding).

We are able to create DBConnection with the MaxDB instance,but we are the getting the following exception on trying to create a prepareStatement:


2016 05 17 10:03:34#+00#INFO#System.out##P000226#http-bio-8041-exec-7#na#spltest#captcha#web#spltest#Borrow prepareStatement from pool failed

Are we missing something here?Kindly help us with this. Thanks

Following are the implementation details

Code to read data

try{

String a = null;

InitialContext ctx = new InitialContext();

DataSource dataSource = (DataSource) ctx.lookup("java:comp/env/jdbc/DefaultDB");

Connection conn = dataSource.getConnection();

PreparedStatement pstmt = conn.prepareStatement("Select '1' as \"ABC\" from dummy");

ResultSet rs = pstmt.executeQuery();

while (rs.next()){

a=rs.getString(1);

System.out.println(a+"result printed from dummy");

}

rs.close();

pstmt.close();

} catch(Exception e){

System.out.println(e.getMessage());

}

Resource reference in web.xml

<resource-ref>

<res-ref-name>jdbc/DefaultDB</res-ref-name>

<res-type>javax.sql.DataSource</res-type>

</resource-ref>

Attachments

data_binding.jpg (16.0 kB)