• Post Reply Bookmark Topic Watch Topic
  • New Topic

JDBC Drive Issue

 
Ajit Sawant
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • 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 jdbcracle: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 ("jdbcracle:thin:@url",user,pwd);
Connection conn = DriverManager.getConnection ("jdbcracleci:@url",user,pwd);

Please advise.
Thanks,
Ajit
 
manoj r patil
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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.
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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.
 
Ninad Kulkarni
Ranch Hand
Posts: 802
Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ Ajit

Also refer to JDBC Tutorial.
JDBC API
Links may help you.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!