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 -> Re: Oracle and JDBC

Re: Oracle and JDBC

From: Paul Boothroyd <paul.boothroyd_at_ntlworld.com>
Date: Tue, 21 Jan 2003 12:29:25 +0000
Message-ID: <3E2D3D25.6080603@ntlworld.com>


I have had similar problems: I believe you have a malformed URL, try the following:

Insert an additional slash between the file: and C:. Remember that URL's comprise <protocol>://<domain>/<path>

Cheers, Paul

Sam wrote:
> 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")});

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 - 06:29:25 CST

Original text of this message

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