7 Replies Latest reply: Sep 18, 2010 12:19 PM by MarceloF.Ochoa RSS

    package oracle.jdbc.driver does not exist

    user5116754
      I get the java compiler error "package oracle.jdbc.driver does not exist"
      when I'm trying to import JDBC Driver with command:
      import oracle.jdbc.pool.OracleDataSource

      What's wrong with that?
      I'm using OracleClient 11.0.2.
      JDBC is installed in C:\app\user\product\11.2.0\client_1\jdbc\

      Thanks so far.
        • 1. Re: package oracle.jdbc.driver does not exist
          601698
          you shouldnt ever be directly importing a specific driver. they are runtime bound by the jdbc driver manager. you should be type casting all calls and variables to the primitives and interfaces given in the jdbc api.

          == stanton
          • 2. Re: package oracle.jdbc.driver does not exist
            user5116754
            You wrote "...you should be type casting all calls and variables to the primitives and interfaces given in the jdbc api."

            How do it work? I'm just trying to establish a connect to my database like this:

            import java.sql.*;

            // We import java.io to be able to read from the command line
            import java.io.*;

            import oracle.jdbc.pool.OracleDataSource;

            class JdbcCheckup
            {
            public static void main(String args[])
            throws SQLException, IOException
            {
            // Load the Oracle JDBC driver
            DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

            // Prompt the user for connect information
            System.out.println("Please enter information to test connection to the database");
            String user;
            String password;
            String database;
            ...
            • 3. Re: package oracle.jdbc.driver does not exist
              601698
              use this as your connection url --> "jdbc:default:connection"

              this assumes you are running "inside" the oracle instance (running on the aurora jvm)

              == stanton
              • 4. Re: package oracle.jdbc.driver does not exist
                601698
                if you are working "outside" the instance (remote client connection) you should be configuring the DriverManager, and instantiating the Driver indirectly:

                http://download.oracle.com/javase/1.5.0/docs/api/java/sql/DriverManager.html

                they show an example of using the "classForName" but that is a kludge at best. you should be either loading the class name references from a property file and bootstrapping them, or configuring them for the jvm to discover.

                also, make sure the driver jar file is on the classpath.

                == stanton
                • 5. Re: package oracle.jdbc.driver does not exist
                  user5116754
                  Thanks for your reply. I'm afraid it's not so easy to follow you. But this link you posted is helpful.
                  Joerg
                  • 6. Re: package oracle.jdbc.driver does not exist
                    user5116754
                    I still fail on the same error. Java compiler don't give me this error anymore, but when I embed this "OrcaleAccess.class" in html I get the error:

                    java.lang.ClassNotFoundException:oracle.jdbc.driver.OracleDriver
                    Can someone give me assist? Thank you

                    ----------------------------------------------------------------------------------------------------------
                    import java.sql.Driver;
                    import java.io.*;
                    import java.util.*;

                    class OracleAccess

                    public static void main(String[] args)

                    Properties x = new Properties();
                    x.put("user","custview");
                    x.put("pw","custview");

                    try

                    String url= "jdbc:oracle:thin:@160.58.32.146:1521:DB_BLEM";
                    Class.forName("oracle.jdbc.driver.OracleDriver");
                    Connection conn = DriverManager.getConnection(url, x);
                    Statement st=conn.createStatement();
                    ResultSet rs=st.executeQuery("select sysdate from dual");

                    while(rs.next())

                    System.out.println(rs.getString(1));
                    System.out.println(rs.getString(2));
                    }
                    }

                    catch(Exception e)

                    System.out.println(e);
                    }
                    }
                    }
                    ----------------------------------------------------------------------------
                    • 7. Re: package oracle.jdbc.driver does not exist
                      MarceloF.Ochoa
                      Hi:
                      If you are running the code outside the Database, I mean not using the code as Java Stored Procedures or any other way running with the internal OJVM functionality.
                      You should add the ojdbc5.jar to the running classpath, the class is inside see below:

                      [mochoa@mochoa odi]$ jar tvf /u01/app/oracle/product/11_2_0_1_0/db_1/jdbc/lib/ojdbc5.jar |grep OracleDriver
                      1578 Fri Jul 31 19:30:10 PDT 2009 oracle/jdbc/OracleDriver.class
                      459 Fri Jul 31 19:30:08 PDT 2009 oracle/jdbc/driver/OracleDriver$1.class
                      13377 Fri Jul 31 19:30:08 PDT 2009 oracle/jdbc/driver/OracleDriver.class
                      950 Fri Jul 31 19:30:08 PDT 2009 oracle/jdbc/driver/OracleDriverExtension.class

                      Best regards, Marcelo.