3 Replies Latest reply: May 11, 2007 5:53 AM by 807606 RSS

    NO suitable driver:oracle n java

    807606
      I am using jdk1.6 n oracle 10.2.0.1.0

      when i run this code ... OracleConnection.java

      import java.sql.*;

      public class OracleConnection
      {
           Connection con;
      public OracleConnection()
      {
           try
           {
                Class.forName("oracle.jdbc.OracleDriver");
                String user = "system";
                String pwd = "simha";
                con = DriverManager.getConnection("jdbc:orcale:thin:@localhost:1521:vinay",user,pwd);

           }catch(Exception e){e.printStackTrace();}
      }
           public static void main(String args[])
           {
                new OracleConnection();
           }
      }


      getting error as

      java.sql.SQLException: No suitable driver
      at java.sql.DriverManager.getConnection(DriverManager.java:545)
      at java.sql.DriverManager.getConnection(DriverManager.java:171)
      at OracleConnection.<init>(OracleConnection.java:13)
      at OracleConnection.main(OracleConnection.java:19)


      i had specified the ojdbc14.jar in the classpath also....plz give me the reasons why i am getting this error n what is the solution?
        • 1. Re: NO suitable driver:oracle n java
          807606
          I think, you should use
          Class.forName( "oracle.jdbc.driver.OracleDriver" )
          Also, you have a typo in jdbc:orcale:thin.

          Tobias
          • 2. Re: NO suitable driver:oracle n java
            807606
            still i am getting the same error
            • 3. Re: NO suitable driver:oracle n java
              807606
              First, you've got the wrong class name for the Oracle driver.
              Secondly, you haven't registered the Oracle driver.

              So... two approaches to fix.

              Approach 1, register the driver manually
              public OracleConnection()
              {
                  try
                  {
                       Driver oracleDriver = (Driver)Class.forName("oracle.jdbc.driver.OracleDriver");
                       DriverManager.registerDriver ( oracleDriver );
                       String user = "system";
                       String pwd = "simha";
                       con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:vinay",user,pwd);
              
                    }
                    catch(Exception e)
                    {
                         e.printStackTrace();
                    }
              }
              Approach 2, register the driver via command line

              Add
                  -Djdbc.drivers=oracle.jdbc.driver.OracleDriver
              to the command line which runs your program.

              regards,
              Owen