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

Home -> Community -> Usenet -> c.d.o.misc -> Oracle and JDBC

Oracle and JDBC

From: Sam <samlai_at_mail.utexas.edu>
Date: Tue, 21 Jan 2003 02:24:54 -0600
Message-ID: <b0j04l$p8c$1@geraldo.cc.utexas.edu>


Hi,

My goal is to allow users of my program to use Oracle drivers without modifying their classpath. I have a question on the difference of these two methods. Why does the first method fail?

P.S. ojdbc14.jar is Oracle's JDBC driver for Java 1.4. It used to be class12.zip.



First method

URLClassLoader classLoader = new URLClassLoader(new URL[]{new URL("file://C:/ojdbc14.jar")});
classLoader.loadClass("oracle.jdbc.driver.OracleDriver"); setDBConnection(DriverManager.getConnection("jdbc:oracle:thin:@localhost:152 1:mud", "wizard", "samlai"));
// Fail... it throws SQLException, but not ClassNotFoundException, so oracle.jdbc.driver.OracleDriver is obviously loaded.

Second method

Class.forName("oracle.jdbc.driver.OracleDriver"); setDBConnection(DriverManager.getConnection("jdbc:oracle:thin:@localhost:152 1:mud", "wizard", "samlai"));
//Succeed, if ojdbc14.jar is in my classpath.

Thanks a lot,

Sam Lai Received on Tue Jan 21 2003 - 02:24:54 CST

Original text of this message

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