wood burning stoves 2.0*
The moose likes JDBC and the fly likes java.lang.NullPointerException in JDBC connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "java.lang.NullPointerException in JDBC connection" Watch "java.lang.NullPointerException in JDBC connection" New topic
Author

java.lang.NullPointerException in JDBC connection

Hebert Tourne
Greenhorn

Joined: Mar 04, 2010
Posts: 4
Hi,
i have the next code to connect a database:

String url = "myURL";
String user = "myUser";
String password = "myPass";

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection c = DriverManager.getConnection(url, user, password);

and when runs throws NullPointerException
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1352)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:321)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:512)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:200)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:30)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:539)
at java.sql.DriverManager.getConnection(DriverManager.java:311)
at java.sql.DriverManager.getConnection(DriverManager.java:348)
at com.po.getConnection(po.java:32)
at com.po.main(po.java:47)

Java: 1.6.0
Oracle Driver: ojdbc6.jar

anybody can help me?
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
Try doing it this way


JDBCSupport - An easy to use, light-weight JDBC framework -
Hebert Tourne
Greenhorn

Joined: Mar 04, 2010
Posts: 4
Hi, i try but same error.

java.lang.NullPointerException
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1352)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:321)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:512)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:200)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:30)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:539)
at java.sql.DriverManager.getConnection(DriverManager.java:311)
at java.sql.DriverManager.getConnection(DriverManager.java:348)
at com.po.getConnection(po.java:35)
at com.po.main(po.java:49)

if i use driver: ojdbc14.jar works fine, but i need to use ojdbc6.jar because i use java 1.6.
Any ideas?
Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.NullPointerException in JDBC connection