This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC 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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
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: 860

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: 19656
    
  18

how to set the class path


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: problem in JDBC connection with jdk6
 
Similar Threads
ResultSet object returning null
Establishing Connections to a Data base on a different machine
Invalid Cursor State HELP!
class not found exception
Help - Statement error!