error connecting to oracle

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paul

    #1

    error connecting to oracle

    hi,

    i'm getting the following error when i try to run the code below to
    connect to an oracle db:

    java.lang.Class notfoundExcepti on:oracle.jdbc. driver.OracleDr iver
    java.sql.SQLExc eption No suitable driver.

    i'm using jdk1.4 installed on a Windows NT 2000 machine. I don't have
    any oracle client installed on my machine. I'm basically connected to
    our office network. The programs compiles but when I try to run it i'm
    getting the error above. I'm fairly new to java & JDBC. I'm not the
    Oracle administrator as well.
    i've browsed the group fairly well but didn't get the answer i needed.
    i also read about the classes111.zip but, i don't think it's
    applicable in my case since I don't have oracle on my PC. Any help
    would be appreciated. Thanks.

    import java.sql.*;
    import java.util.*;
    import java.awt.*;

    public class RPASelect {
    public static void main(String args[]) {
    String url = "jdbc:oracle:th in:@nnnn:nnnn:n nnn";
    Connection con;
    String queryString;
    queryString = "select * from RPA.RPA_RESOURC E where
    CUNYRPA.RPA_RES OURCE.COLCD = '**'";

    Statement stmt;
    ResultSet rs;

    try {
    DriverManager.r egisterDriver (new
    oracle.jdbc.dri ver.OracleDrive r());
    //Class.forName(" oracle.jdbc.dri ver.OracleDrive r");
    System.out.prin tln("JDBC driver loaded");
    }
    catch(java.lang .ClassNotFoundE xception e) {
    System.err.prin t("ClassNotFoun dException: ");
    System.err.prin tln(e.getMessag e());
    }

    try {
    con = DriverManager.g etConnection(ur l, "myID", "myPass");
    stmt = con.createState ment();
    rs = stmt.executeQue ry(queryString) ;
    while (rs.next()) {
    System.out.prin tln (rset.getString (1));
    // String s = rs.getString("C OF_NAME");
    // float n = rs.getFloat("PR ICE");
    // System.out.prin tln(s + " " + n);
    stmt.close();
    con.close();
    }
    catch(SQLExcept ion ex) {
    System.err.prin tln("SQLExcepti on: " + ex.getMessage() );
    }
    }
    }
  • Christopher Blunck

    #2
    Re: error connecting to oracle

    You need the Oracle 9i Thin JDBC Driver. This is usually packaged
    in a JAR file, and can most likely be found on oracle.com

    -c

    Comment

    Working...