| Author |
Cannot register driver
|
Mujahid Al-okaidi
Greenhorn
Joined: May 31, 2008
Posts: 8
|
|
Hi there I have an application that works fine when I run it from the eclipse IDE but when I exported it to a jar file and execute the jar it dosent go past the line: OracleDriver driver = new OracleDriver(); It dosen't throw an exception it just stays there forever. any idea why that is?
|
 |
Shailesh Chandra
Ranch Hand
Joined: Aug 13, 2004
Posts: 1076
|
|
Can you post the code of method, where you are facing this problem. Do you have OracleDriver in your run-time path, when you run your application as jar ? Thanks, Shailesh
|
Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
|
 |
Scott Selikoff
Saloon Keeper
Joined: Oct 23, 2005
Posts: 3652
|
|
That's not the way you initialize a driver. Have you tried JDBC tutorials for oracle? Could you post all of your initialization code. [ August 18, 2008: Message edited by: Scott Selikoff ]
|
My Blog: Down Home Country Coding with Scott Selikoff
|
 |
Mujahid Al-okaidi
Greenhorn
Joined: May 31, 2008
Posts: 8
|
|
This is the method and executes fine as I said but when I export it to a jar it stops at line (1) and doesn't throw an exception. note: Message is a JFrame that will display the arguments I added it for debugging as System.out.println doedn't give an output from an executable jar. Thanks private void connect() throws SQLException { Message.setText("Connecting"); try { OracleDriver driver = new OracleDriver(); //(1) Message.setText("Trying"); DriverManager.registerDriver (driver); } catch(Exception e) { Message.setText(e.getMessage()); } Message.setText("past exception"); connection = DriverManager.getConnection("jdbc racle:thin:@oracle.*****.com:1521:campus","*****", "*****"); Message.setText("Connected"); connected = true; }
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
|
Then presumably you haven't set up your jar file in such a way that the driver is in its classpath. Are you running the jar as an executable jar? If so, what's in the Class-Path entry in its manifest?
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12929
|
|
I don't know what the exact cause is of your bug, but to echo what Scott said: OracleDriver driver = new OracleDriver(); DriverManager.registerDriver (driver); This is not the correct way to initialize the JDBC driver. You're not supposed to register the driver yourself with the DriverManager. Instead of the above two lines, you should do something like this: Class.forName("oracle.jdbc.driver.OracleDriver");
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Mujahid Al-okaidi
Greenhorn
Joined: May 31, 2008
Posts: 8
|
|
Originally posted by Paul Clapham: Then presumably you haven't set up your jar file in such a way that the driver is in its classpath. Are you running the jar as an executable jar? If so, what's in the Class-Path entry in its manifest?
I am running the a jar and I think the problem could be the mainfest file, I have listed the ontents of the file, please let me know what I need to add. Manifest-Version: 1.0 Sealed: true Main-Class: Main Thanks
|
 |
Rene Larsen
Ranch Hand
Joined: Oct 12, 2001
Posts: 1179
|
|
Working with Manifest Files: The Basics
Originally posted by Mujahid Al-okaidi: I am running the a jar and I think the problem could be the mainfest file, I have listed the ontents of the file, please let me know what I need to add. Manifest-Version: 1.0 Sealed: true Main-Class: Main Thanks
|
Regards, Rene Larsen
Dropbox Invite
|
 |
 |
|
|
subject: Cannot register driver
|
|
|