• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in JDBC connection with jdk6

 
Arpeeta Halder
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 859
Chrome IBM DB2 Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!! But, how I can set this class path? It will be very helpfull. If you help me.
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to set the class path
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic