Milleniumlegend
IS-IT--Management
- Dec 16, 2003
- 135
I am trying to run the JDBC Connection on a Local Database. The SID = TST9. The user who has access to the SID is user. The program compiles fine. But for some reason it would not run. When I run I get an exception. Could someone please let me know what could be the problem.
Code:
// Establish a connection to a Oracle database using JDBC.
import java.sql.*;
class JdbcTest1 {
public static void main (String[] args) {
try {
// Step 1: Load the JDBC driver.
Class.forName("oracle.jdbc.driver.OracleDriver");
// Step 2: Establish the connection to the database.
String url = "jdbc:oracle:thin:@//localhost:1521/tst9";
Connection conn = DriverManager.getConnection(url,"user","password");
} catch (Exception e) {
System.err.println("Got an exception! ");
System.err.println(e.getMessage());
}
}
}
Code:
C:\winpack\samples>java JdbcTest1
Exception in thread "main" java.lang.NoClassDefFoundError: JdbcTest1