By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,990 Members | 1,741 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,990 IT Pros & Developers. It's quick & easy.

error connecting to oracle

P: n/a
hi,

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

java.lang.ClassnotfoundException:oracle.jdbc.drive r.OracleDriver
java.sql.SQLException 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:thin:@nnnn:nnnn:nnnn";
Connection con;
String queryString;
queryString = "select * from RPA.RPA_RESOURCE where
CUNYRPA.RPA_RESOURCE.COLCD = '**'";

Statement stmt;
ResultSet rs;

try {
DriverManager.registerDriver (new
oracle.jdbc.driver.OracleDriver());
//Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("JDBC driver loaded");
}
catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con = DriverManager.getConnection(url, "myID", "myPass");
stmt = con.createStatement();
rs = stmt.executeQuery(queryString);
while (rs.next()) {
System.out.println (rset.getString (1));
// String s = rs.getString("COF_NAME");
// float n = rs.getFloat("PRICE");
// System.out.println(s + " " + n);
stmt.close();
con.close();
}
catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.