I want to connect Oracle 10g Express Edition and Java, the steps that I have followed are:
Configure my classpath with the following files:
C:\oraclexe\app\oracle\product\10.2.0\server\jdbc\lib\ojdbc14.jar
C:\Program Files\Java\jdk1.7.0_01\bin
C:\oraclexe\app\oracle\product\10.2.0\server\BIN
Then I have tried the following program to connect it with OCI driver:
import java.sql.*;
public class OracleOCIConnection
{
public static void main(String args[])
{
try
{
// load oracle driver
Class.forName("oracle.jdbc.driver.OracleDriver");
// connect using Native-API (OCI) driver
Connection con = DriverManager.getConnection("jdbc:oracle:oci8:@","hr","hr" );
System.out.println("Connected Successfully To Oracle using OCI driver");
con.close();
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
and also this using the Thin driver:
import java.sql.*;
public class OracleThinConnection
{
public static void main(String args[])
{
try
{
// load oracle driver
Class.forName("oracle.jdbc.driver.OracleDriver");
// connect using Thin driver
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","hr","hr");
System.out.println("Connected Successfully To Oracle");
con.close();
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
In both cases the program compiles, but the line that throws an error is:
Class.forName("oracle.jdbc.driver.OracleDriver");
Any help? Thanks