• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Problem with conn to oracle

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hai
i have a problem connecting to oracle 9i.
here is the code:-

import java.sql.*;
class TestThinApp {
public static void main (String args[])
throws ClassNotFoundException, SQLException
{
Connection conn=null;
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("connection success");
}catch(Exception e)
{
System.out.println("Inside class.forname ");
System.out.println(e);
}
try{
conn = DriverManager.getConnection(
"jdbc racle:thin:@10.10.20.10:1521:ero","mahesh","mahesh");
}catch(Exception e)
{ System.out.println("Inside Drivermanager.getconn ");
System.out.println(e);
}
}
}

i am getting an error like:
Inside class.forname
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
Inside Drivermanager.getconn
java.sql.SQLException: No suitable driver


plz solve this.
thanks and regards,
mahesh
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have u add the classpath of your Oracle JDBC driver, while compiling your application? :roll:
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
set CLASSPATH.;location to jar file of oracle jdbc;%CLASSPATH%
 
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ko Ko Naing:
Have u add the classpath of your Oracle JDBC driver, while compiling your application? :roll:



Ko Ko,
He is facing a Exception during runtime, it is not a compile time problem.
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Pradeep Bhat:


Ko Ko,
He is facing a Exception during runtime, it is not a compile time problem.



Yes, But when program call Class.forName("oracle.jdbc.driver.OracleDriver");

It's MUST find all library from CLASSPATH environment.

So, you should be configed CLASSPATH refer to oracle jdbc driver.
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Pradeep Bhat:


Ko Ko,
He is facing a Exception during runtime, it is not a compile time problem.



Well, Pradeep, as Somkiat mentioned above, even though it is not compile time problem, if Mahesh did not add the classpath, how can his application find the driver?

Since "oracle.jdbc.driver.OracleDriver" is a String, it will be able to pass the compile time, but not the runtime...
 
Pradeep bhatt
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Well, Pradeep, as Somkiat mentioned above, even though it is not compile time problem, if Mahesh did not add the classpath, how can his application find the driver?



Right, but your statement confused me.
 
Mahesh Pinnamaneni
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks guys,
the CLASSPATH ultimately made my page work.
regards,
Mahesh
 
eat bricks! HA! And here's another one! And a tiny ad!
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic