Oracle Connection Problem...

I have a problem connecting to oracle and I am unsure why.. My TNS is correct I can use any sql program to log into my database. I have the ojdbc14.jar file and it is located in the same directory as my .class and .java file. My classpath includes . so it will include the files in the directory I execute java from.

The following is data show what I am doing.. Please let me know what is wrong. Don't worry about DataObjects this is a seperate application than Test.

C:\Caps\java>dir

Volume in drive C has no label.

Volume Serial Number is ECE1-58EB

Directory of C:\Caps\java

09/09/2005 01:55 AM<DIR> .

09/09/2005 01:55 AM<DIR> ..

09/09/2005 01:39 AM 3,434 DataObject.class

09/09/2005 01:06 AM 4,042 DataObject.java

09/08/2005 08:04 PM 1,200,046 ojdbc14.jar

09/09/2005 01:55 AM 1,083 Test.class

09/09/2005 01:54 AM 1,111 Test.java

5 File(s)1,209,716 bytes

2 Dir(s) 31,031,754,752 bytes free

C:\Caps\java>java Test

Could not find the database driver

java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

Here is the code of DataObject.java

import java.sql.Connection;

import java.sql.Statement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.ResultSetMetaData;

import java.sql.DriverManager;

import javax.swing.JOptionPane;

public class Test

{

public Test()

{

Connection connection = null;

try {

// Load the JDBC driver

String driverName = "oracle.jdbc.driver.OracleDriver";

Class.forName(driverName);

}

catch (ClassNotFoundException e)

{

System.out.println("Could not find the database driver");

System.out.println(e.toString());

JOptionPane.showMessageDialog(null, "Error:: Could not find the database driver\n" + e.toString());

System.exit(1);

}

/* catch (SQLException e)

{

// Could not connect to the database

System.out.println("Couldn't connect");

JOptionPane.showMessageDialog(null, "Error:: Connecting to database\n" + e.toString());

System.exit(1);

}

*/

}

public static void main(String[] args) throws SQLException

{

Test t= new Test();

}

}

[2388 byte] By [jsterrett] at [2007-11-25 20:11:00]
# 1
Hi~ Perhaps.. you should put "ojdbc14.jar" to "%JAVA_HOME%\jre\lib\ext" directory..or.. do you set something.... classpath variable ... before "."?check...Good luck!
bluew at 2007-7-4 14:40:46 > top of Java-index,Desktop,Sun Java Desktop System...
# 2

I tried that and it didn't work. I got the same error. For some reason it looks like its not liking my jar file or system variables. I tried grabbing another jar file but that didn't work. Below is my system variables incase this helps any.

CLASSPATH=C:\oracle\ora9205\jdbc\lib;.

PATH=C:\Program Files\Java\jdk1.5.0_04\bin;C:\oracle\ora9205\bin;%SystemRoot%\system32;%SystemR oot%;%SystemRoot%\System32\Wbem;C:\Program Files\Visual Networks\Dial Analysis\;C:\Program Files\WinZip;c:\Program Files\Common Files\Adaptec Shared\System;C:\Program Files\MySQL\MySQL Server 4.1\bin

jsterrett at 2007-7-4 14:40:46 > top of Java-index,Desktop,Sun Java Desktop System...