Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
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 The Software Craftsman this week in the Agile 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: 19958
    
  25

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
 
 
subject: problem in JDBC connection with jdk6