JDBC Driver not found
441137Mar 29 2005 — edited Apr 6 2005Hi:
I am new to Java and JDBC. I have downloaded J2SE SDK jsdk1_4_2_07.
I downloaded oracle driver files classes12.zip nls_charset12.zip and placed them in a folder jdbcdrivers.
I set CLASSPATH to c:\jdbcdrivers\classes12.zip;c:\jdbcdrivers\nls_charset12.zip;.
here is the test code.
import java.sql.*;
import oracle.jdbc.driver.*;
/**
* This class will test the DMS API
*
**/
public class TestDMSApi {
public static void main(String args[]) {
// register the driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
try
{
// Load the JDBC driver
String driverName = "oracle.jdbc.OracleDriver";
Class.forName(driverName);
// url connection string format, a valid format is: "host:port:sid"
String urlString = "jdbc:oracle:thin:@XXXX";
String userName = "XXX";
String password = "XXX";
// Connect to the database
// You must put a database name after the @ sign in the connection URL.
// You can use either the fully specified SQL*net syntax or a short cut
// syntax as ::. The example uses the short cut syntax.
Connection con =
DriverManager.getConnection(urlString, userName, password);
Statement stat=con.createStatement();
stat.executeQuery("select * from XXXX");
}
catch(Exception e)
{
System.out.println("error"+e);
}
}
I am getting the error:
C:\JimsJavaCode\TestDMSApi\TestDMSApi.java:14: package oracle.jdbc.driver does not exist
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
It looks like it should work but I am missing something. Any help will be appreciated. Thanks