Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: JDBC - Novice question

Re: JDBC - Novice question

From: FC <fcamussa_at_hotmail.com>
Date: Fri, 16 Jul 1999 14:58:19 +0200
Message-ID: <7mnac9$1plu$1@stargate1.inet.it>


Have you corretly configured your CLASSPATH enviroment variable by including the ORACLE JDBC classes ?

Tom Nixon <Tom_at_absoluteinternet.co.uk> wrote in message news:378F1120.FAF79C2E_at_absoluteinternet.co.uk...
> 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 - 07:58:19 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US