Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Y.E.L.P. on JDBC-Oracle 8i

Y.E.L.P. on JDBC-Oracle 8i

From: Richard Cuello <rc370_at_columbia.edu>
Date: Sat, 21 Aug 1999 22:26:00 -0400
Message-ID: <37BF5FB8.EF535C83@columbia.edu>


Hi. I'm trying to get a connetion to an Oracle 8i database set up on my NT workstation. I st the classpath at the system environment as .;c:\jdk1.2.1\lib\classes.zip;e:\oracle\ora81\jdbc\lib\Classes111.zip

the name of the database is bito.neomenia.com the username is abc
the password is 123

Below is the code and the result at the c:\ prompt when it is compiled. Any Suggestions on why it isn't working?

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 and
get 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:bito", "abc", "123"    // connection =
DriverManager.getConnection("jdbc:oracle:thin:@lambdael:1521:bito", "abc", "123");

      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 key, val from
test");

}

    catch(SQLException e) {

       e.printStackTrace();
}

    finally {

       try {
         connection.close();
       }
       catch(SQLException e) {
         e.printStackTrace();
       }

}

  }
}

RESULT Syntax: java SimpleConnection DRIVER URL UID PASSWORD Received on Sat Aug 21 1999 - 21:26:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US