Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> JDBC - Novice question
hi
I am trying to connect to an Oracle database using JDBC. I'm using JDK
v1.2.2 and I
have downloaded the Oracle JDBC driver from their website. I am trying
to compile an
example program (see below) and get an error because the class
oracle.jdbc.driver
doesn't seem to be anywhere (I have searched the entire hard disk so it
shouldn't be a
classpath issue). I had assumed that the purpose of downloading the
Oracle driver was to
get this class file. Does anyone know what I am doing wrong?
cheers
Tom
here's the sourcecode:
import java.sql.*;
public class JDBCExample {
public static void main(String args[]) throws SQLException {
// This line generates the "class not found" compiler error DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn =
DriverManager.getConnection("jdbc:oracle:thin:@dlsun137:5521:sol1",
"scott", "tiger");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select ename, emp");
while(rs.next()) {
String name = rs.getString(1);
int number = rs.getInt(2);
System.out.println(name + " " + number);
}
rs.close();
conn.close();
}
}
Received on Fri Jul 16 1999 - 06:01:52 CDT
![]() |
![]() |