This week's book giveaway is in the OCAJP forum. We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line! See this thread for details.
Can anyone help me on this one? I've been struggled long to configure Tomcat for database pooling (to Oracle) using DBCP... And finally this is the error I got:
DBCP borrowObject failed: null java.lang.NullPointerException at org.apache.commons.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:237) at org.apache.commons.dbcp.PoolableConnectionFactory.activateObject(PoolableConnectionFactory.java:273) at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(Unknown Source) at org.apache.commons.dbcp.AbandonedObjectPool.borrowObject(AbandonedObjectPool.java:117) at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:110) at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:312)
Here's the code of how I got the DataSource and Connection:
Context initContext = new InitialContext(); Context envContext = (Context)initContext.lookup("java:comp/env"); DataSource dbSource = (DataSource) envContext.lookup("jdbc/oracle"); Connection con = dbSource.getConnection();
Tomcat did get the datasource back, but failed at the get connection line. What's wrong? I followed the instructions on Apache website on how to configure Database pool using DBCP... I tried to follow the example code in DBCP website to manually configure the database pool and it succeeded without any problem. So my system setup shouldn't have any problem... Can any one give me any idea of what's wrong here? Any feedback is highly appreaciated! I really want to know why Tomcat can not initialze the Database pool successfully!