• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JDBC Drive Issue

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to test JDBC connection, but I geting errors for two tdrivers that I'm trying to load
1) DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
The above fails to compile with error
testjdbc.java:9: package oracle.jdbc.driver does not exist
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
^
1 error
2) DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());
The above compiles with warning and when run give the error
Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:oracle:thin@url
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at testjdbc.main(testjdbc.java:21)
--
For above 2 scenacios, tried with the below connections separately.
Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@url",user,pwd);
Connection conn = DriverManager.getConnection ("jdbc:oracle:oci:@url",user,pwd);

Please advise.
Thanks,
Ajit
 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the error you are getting the the first case while passing Oracle driver instance?

While using sun's driver, I am not really sure if it would be suitable to connect to Oracle or not.
 
Ajit Sawant
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Program failes to compile with message
testjdbc.java:9: package oracle.jdbc.driver does not exist
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
^
I have dowloaded jdbc driver ojdbc14.jar and it in my program's directory where I'm running javac command.. The current CLASSPATH IS: .;F:\myjava
 
Ajit Sawant
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is working fine. I put the *.jar file in ...\lib\ext. But I'm another error. I'll open a new thread for that.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ajit Sawant wrote:It is working fine. I put the *.jar file in ...\lib\ext.



Do you mean - JRE_HOME/lib/ext? If yes, then that's not the right place to put your driver jars.

I have dowloaded jdbc driver ojdbc14.jar and it in my program's directory where I'm running javac command.. The current CLASSPATH IS: .;F:\myjava



All you have to is, set the CLASSPATH correctly. See http://faq.javaranch.com/java/HowToSetTheClasspath]HowToSetTheClasspath.
 
Ranch Hand
Posts: 814
Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@ Ajit

Also refer to JDBC Tutorial.
JDBC API
Links may help you.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic