I'm fairly inexperienced with Java and Jars and I'm just completely lost as to what I should be trying to do.
I have an oracle driver ojbc7.jar. It needs to stay where it is because I'm on a server with limited permissions.
I also have code which should use the driver. Feel free to take a look, but I don't think it will help.
import java.sql.*;
import java.math.*;
public class LoginTest{
public static void main(String[] args){
Connection con;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch(ClassNotFoundException ex) {
System.out.println("Error: unable to load driver class!");
System.exit(1);
}
try {
con = DriverManager.getConnection("jdbc:oracle:thin:@oracle-prod:1521:OPROD", "username", "password");
con.close();
} catch(Exception ex) {
System.out.println("Error: Connection Failure!");
System.exit(1);
}
}
}
My understanding is that my code needs to know the path to my driver. Other suggestions I've found suggest using the following format:
Compile:
javac -cp ojdbc7.jar LoginTest.java
Run:
java -cp ojdbc7.jar LoginTest
BUT, this returns the error:
Error: Could not find or load main class LoginTest
So now I'm stumped. Do you know what I'm trying to do? What should be doing differently?