aspose file tools
The moose likes JDBC and Relational Databases and the fly likes problem in JDBC connection with jdk6 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "problem in JDBC connection with jdk6" Watch "problem in JDBC connection with jdk6" New topic
Author

problem in JDBC connection with jdk6

Arpeeta Halder
Greenhorn

Joined: May 08, 2012
Posts: 2
I am facing a lot of problems establising a connection with jdbc and java. please, help me out.

class MyConnection
{

public static Connection getConnection()
{

Connection con=null;
try
{

Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbcracle:thin:@localhost:1527:XE", "system", "1234");
}catch(ClassNotFoundException cnfe)
{
System.out.println("driver not found " + cnfe);
}catch(SQLException se)
{
System.out.println("prob in con. establishment " + se);
}
return con;
}

}

after using the following coding to insert a data into database . I am getting an error:

driver not found java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
Exception in thread "main" java.lang.NullPointerException
at DataInsert.insert(MyConnection.java:94)
at MyConnection.main(MyConnection.java:231)
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

You need to have the oracle JDBC driver on your CLASSPATH.

This is usually ojdbc14.jar or a modern version, ojdbc5.jar etc.

WP
Arpeeta Halder
Greenhorn

Joined: May 08, 2012
Posts: 2
Thanks!! But, how I can set this class path? It will be very helpfull. If you help me.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 20041
    
  30

how to set the class path


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in JDBC connection with jdk6
 
It's not a secret anymore!