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: <tedchyn_at_yahoo.com>
Date: Fri, 16 Jul 1999 17:54:05 GMT
Message-ID: <7mnrjn$m73$1@nnrp1.deja.com>


In article <378F1120.FAF79C2E_at_absoluteinternet.co.uk>,   Tom Nixon <Tom_at_absoluteinternet.co.uk> 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?

Tom, class comes from two source - one from classes111.zip, the other one come from the java class you created. if you use nt in envrionment variable set classpath to .;<d:\jdbc\classes111.zip the dot tells nt to search current directory.

Ted Chyn
> 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();
> }
> }
>
>

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't. Received on Fri Jul 16 1999 - 12:54:05 CDT

Original text of this message

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