Quantcast
Channel: MySQL Forums - Connector/J, JDBC and Java
Viewing all articles
Browse latest Browse all 884

Problem with connection pooling (1 reply)

$
0
0
Hi,

I'm running into the following exception with connection pooling when trying to get a connection from the pool:

Cannot create JDBC driver of class '' for connect URL 'null'
java.lang.NullPointerException
at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507)
at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476)
at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
at java.sql.DriverManager.getDriver(DriverManager.java:253)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at nl.timeware.data.TDataBase.connectFromPool(TDataBase.java:83)
.....

In my application's /WEB-INF/web.xml I have:
<resource-ref>
<description>MySQL DB Connection pooling</description>
<res-ref-name>jdbc/mysqldb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

In my application's /META-INF/context.xml I have:
<Context>
<Resource name="jdbc/mysqldb" auth="Container" type="javax.sql.DataSource"
maxActive="40" maxIdle="10" maxWait="5000"
testWhileIdle="true" timeBetweenEvictionRunsMillis="300000"
username="mysqluser" password="mysqlpswd" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/mysqldb?useOldAliasMetadataBehavior=true"/>
</Context>

I'm connecting as follows:
public void connectFromPool() throws Exception
{ InitialContext jndiContext = new InitialContext();
if (jndiContext == null)
throw new Exception("No JNDI context");
DataSource ds = (DataSource)jndiContext.lookup("java:/comp/env/jdbc/mysqldb");
if (ds == null)
throw new Exception("No data source available");
connection = ds.getConnection(); // <-- this is were the above exception occurs
connection.setAutoCommit(true);
}

I know the database name, MySQL username and password are working correctly. The same configuration works OK on another host
(with slightly different minor software version numbers). I have the latest mysql-connector-java-5.1.14-bin on the tomcat\lib directory.

Where should I go from here, what can I check?

Thanks, regards,
Paul.

Viewing all articles
Browse latest Browse all 884

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>