class not found exception

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vasavimaruthi
    New Member
    • Dec 2007
    • 2

    class not found exception

    hi,
    i got class not found exception of a small jdbc program in windows.

    the program is like this[code=java]
    import java.sql.*;
    public class Db1
    {
    public static void main(String a[]) throws Exception
    {
    Class.forName(" oracle.jdbc.dri ver.OracleDrive r");
    //Driver drv=new oracle.jdbc.dri ver.OracleDrive r();
    //DriverManager.r egisterDriver(d rv);
    Connection con=DriverManag er.getConnectio n("jdbc.oracle: thin:@localhost :1521:orcl","sc ott","tiger");
    System.out.prin tln("concls->"+con.getClass ());

    }
    }
    and the problem is like this


    E:\work>javac Db1.java
    Db1.java:21: cannot find symbol
    symbol : variable con
    location: class Db1
    System.out.prin tln("concls->"+con.getClass ());
    ^[/code]
    1 error

    E:\work>javac Db1.java

    E:\work>java Db1
    java.lang.Class NotFoundExcepti on: oracle.jdbc.dri ver.OracleDrive r
    Exception in thread "main" java.lang.NullP ointerException
    at Db1.main(Db1.ja va:21)

    E:\work>javac Db1.java

    E:\work>java Db1
    Exception in thread "main" java.lang.Class NotFoundExcepti on: oracle.jdbc.dri ver.
    OracleDriver
    at java.net.URLCla ssLoader$1.run( Unknown Source)
    at java.security.A ccessController .doPrivileged(N ative Method)
    at java.net.URLCla ssLoader.findCl ass(Unknown Source)
    at java.lang.Class Loader.loadClas s(Unknown Source)
    at sun.misc.Launch er$AppClassLoad er.loadClass(Un known Source)
    at java.lang.Class Loader.loadClas s(Unknown Source)
    at java.lang.Class Loader.loadClas sInternal(Unkno wn Source)
    at java.lang.Class .forName0(Nativ e Method)
    at java.lang.Class .forName(Unknow n Source)
    at Db1.main(Db1.ja va:6)

    E:\work>

    I already set the classpath and i already check the Services.msc also.
    there is no problem over their.

    i am using oracle 9 software
    Last edited by debasisdas; Dec 17 '07, 01:01 PM. Reason: Formatted using code tags.
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Question moved to java forum .

    Comment

    • BigDaddyLH
      Recognized Expert Top Contributor
      • Dec 2007
      • 1216

      #3
      Originally posted by vasavimaruthi
      I already set the classpath
      But what did you set it to? Does it include the driver's jar? I don't think so!

      Comment

      • vasavimaruthi
        New Member
        • Dec 2007
        • 2

        #4
        Originally posted by BigDaddyLH
        But what did you set it to? Does it include the driver's jar? I don't think so!

        the necessary jar file for my jdbc driver is classes12.jar
        i copied tht into my working directory.. like this

        E:\work\classes 12.jar

        Comment

        • BigDaddyLH
          Recognized Expert Top Contributor
          • Dec 2007
          • 1216

          #5
          Originally posted by vasavimaruthi
          the necessary jar file for my jdbc driver is classes12.jar
          i copied tht into my working directory.. like this

          E:\work\classes 12.jar
          It doesn't matter where you put library jars, like your driver jar, as long as the jar is on the classpath!

          Comment

          Working...