You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Pruitt, Byron S" <st...@hp.com> on 2015/09/17 21:02:59 UTC

[dbcp] PoolingDataSourceExample with MySQL exception

I got the PoolingDataSourceExample.java up and running using Vertica driver easily enough.
I now need to switch to MySQL.  I switched out the driver and the uri particulars.  But I am getting the exception below.  Interesting enough I expected issues with Vertica, but not MySQL.  You just never know.

Exception in thread "main" java.lang.NullPointerException
	at java.util.Hashtable.put(Hashtable.java:459)
	at java.util.Properties.setProperty(Properties.java:166)
	at com.mysql.jdbc.NonRegisteringDriver.parseURL(NonRegisteringDriver.java:804)
	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:316)
	at java.sql.DriverManager.getConnection(DriverManager.java:664)
	at java.sql.DriverManager.getConnection(DriverManager.java:208)
	at org.apache.commons.dbcp2.DriverManagerConnectionFactory.createConnection(DriverManagerConnectionFactory.java:79)
	at org.apache.commons.dbcp2.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:256)
	at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:868)
	at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:435)
	at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363)
	at org.apache.commons.dbcp2.PoolingDataSource.getConnection(PoolingDataSource.java:134)
	at com.hp.mo.tas.pool.test.DriverPoolTest.main(DriverPoolTest.java:58)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)


My setup hasn't really changed much from the working Vertica.

Properties dbProp = new Properties();
        dbProp.put("user", aUser);
        dbProp.put("password", aPw);
        dbProp.put("loginTimeout", "35");
        dbProp.put("binaryBatchInsert", "true");
        dbProp.put("autocommit", false);
        String db = "jdbc:mysql://" + "localhost:3306" + "/" + aDb;
        DataSource dataSource = setupDataSource(db, dbProp);

Thanks in advance.

-S
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


RE: [dbcp] PoolingDataSourceExample with MySQL exception

Posted by "Pruitt, Byron S" <st...@hp.com>.
I traced using my IDE's decompiler and it appears to blowing up trying to create a fabric driver, or so it appears.  It is not discovering my user and pw properties even though they appear to be passed in via the properties object.
I have the MySQL 5.1.36 JConnector.  I don't think this is what I need right now, perhaps an earlier version is best.



-----Original Message-----
From: Pruitt, Byron S [mailto:steve.pruitt@hp.com] 
Sent: Thursday, September 17, 2015 3:03 PM
To: Commons Users List
Subject: [dbcp] PoolingDataSourceExample with MySQL exception

I got the PoolingDataSourceExample.java up and running using Vertica driver easily enough.
I now need to switch to MySQL.  I switched out the driver and the uri particulars.  But I am getting the exception below.  Interesting enough I expected issues with Vertica, but not MySQL.  You just never know.

Exception in thread "main" java.lang.NullPointerException
	at java.util.Hashtable.put(Hashtable.java:459)
	at java.util.Properties.setProperty(Properties.java:166)
	at com.mysql.jdbc.NonRegisteringDriver.parseURL(NonRegisteringDriver.java:804)
	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:316)
	at java.sql.DriverManager.getConnection(DriverManager.java:664)
	at java.sql.DriverManager.getConnection(DriverManager.java:208)
	at org.apache.commons.dbcp2.DriverManagerConnectionFactory.createConnection(DriverManagerConnectionFactory.java:79)
	at org.apache.commons.dbcp2.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:256)
	at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:868)
	at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:435)
	at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363)
	at org.apache.commons.dbcp2.PoolingDataSource.getConnection(PoolingDataSource.java:134)
	at com.hp.mo.tas.pool.test.DriverPoolTest.main(DriverPoolTest.java:58)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)


My setup hasn't really changed much from the working Vertica.

Properties dbProp = new Properties();
        dbProp.put("user", aUser);
        dbProp.put("password", aPw);
        dbProp.put("loginTimeout", "35");
        dbProp.put("binaryBatchInsert", "true");
        dbProp.put("autocommit", false);
        String db = "jdbc:mysql://" + "localhost:3306" + "/" + aDb;
        DataSource dataSource = setupDataSource(db, dbProp);

Thanks in advance.

-S
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org