• 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

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: 8945
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: 8945
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic