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();
}
}

