• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Cannot register driver

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author
Posts: 4281
34
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Mujahid Al-okaidi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:oracle:thin:@oracle.*****.com:1521:campus","*****", "*****");
Message.setText("Connected");
connected = true;
}
 
Sheriff
Posts: 26943
83
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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");
 
Mujahid Al-okaidi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic