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

From: C. Ferguson <c_ferguson_at_rationalconcepts.com>
Date: Sat, 21 Aug 1999 21:38:51 -0700
Message-ID: <37BF7EDB.A1D576_at_rationalconcepts.com>


Hi Richard,
   you are getting the error because you didn't pass in 4 parameters.  Please read some java books to become familiar with the language.
  The error is getting kicked out by the following lines of code in main()
     if (args.length != 4) {
       System.out.println("Syntax: java SimpleConnection " + "DRIVER URL
UID PASSWORD");
       return;
    }

Good Luck,
cindy

Richard Cuello wrote:

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:_at_lambdael:1521:bito", "abc", "123"
   // connection =
DriverManager.getConnection("jdbc:oracle:thin:_at_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 Sun Aug 22 1999 - 06:38:51 CEST

Original text of this message