Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: JDBC - Novice question
Hi Tom,
I use jdk1.2.1 with Oracle 8.0.4. I downloaded the thin client from
Oracle a while ago, but it basically works this way. You download the
client from Oracle, extract the classes111.zip file from that download.
Do not inflate classes111.zip. Reference this classes111.zip in your
classpath.
e.g. javac -classpath .:/export/opt/oracle/ora8/jdbc/lib/classes111.zip
*.java
where /export/opt/oracle... is the path to the driver.
Hope that helps.
Cindy
Tom Nixon wrote:
> 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 - 14:28:18 CDT