Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> H.E.L.P. with JDBC driver
Hi Java and Oracle jedi's,
Below is an JDBC driver. I have already initiated it with the user and password field. Below at (@lambdael:1521:itchy) I need to substitute the url and machine fields. I jave oracle 8 installed on my personal computer which is running on my windows workstation NT. I'm not connected to a server. Any suggestions on what I should substitute to get a connection to my database?
Thanks,
Richard
//Make sure you set the classpath pointing to the folder of your
classes111.zip
//as well as the classpath where your classes are saved.
//set CLASSPATH=C:\Program Files\Oracle\AppBuilder
1.0\jdbc\lib\Classes111.zip;c:\ndesjard\java
import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException;
/**
* The SimpleConnection class is a command line application * that accepts the following command line: * java SimpleConnection DRIVER URL UID PASSWORD * If the URL fits the specified driver, it will then load the driver andget a connection
class SimpleConnection {
public static void main(String args[]){
Connection connection = null;
// Process the command line
if (args.length != 4) {
System.out.println("Syntax: java SimpleConnection " + "DRIVER URL
UID PASSWORD");
return;
}
try{ //load the driver "oracle.jdbc.driver.OracleDriver"
Class.forName(args[0]);
}
catch(Exception e){
e.printStackTrace(); //System.out.println("Failed to load Oracle driver"); return;
try { //"jdbc:oracle:thin:@lambdael:1521:itchy", "cta", "student" );
// connection =
DriverManager.getConnection("jdbc:oracle:thin:@lambdael:1521:itchy",
"cta", "student" );
connection = DriverManager.getConnection(args[1], args[2], args[3]);
System.out.println("Connection Successful");
//Do whatever queries or updates here //Statement stmt = conn.createStatement (); //ResultSet rset = stmt.executeQuery ("select * from course");
e.printStackTrace();
}
finally {
try { connection.close(); } catch(SQLException e) { e.printStackTrace(); }
![]() |
![]() |