How to load specified version of oracle.jdbc.OracleDriver?
Hi.
I've faced problem while working with application that accesses different versions of Oracle(10gR2 and old one 8.0.5).
I have 2 jdbc libraries: classes12.zip(Oracle 8.0.5) and ojdbc14.jar(Oracle 10g).
In both libraries there is class oracle.jdbc.OracleDriver.
Is there any way to load specific driver, by classLoader?
i guess i need 2 method like this:
...
public Connection getOra8Connection(String uri,String username, String passwd){
...
//ClassLoader loads Ora8 driver and Instantiate Connection obj
...
}
public Connection getOra10gConnection(String uri,String username, String passwd){
...
//ClassLoader loads Ora10 driver and Instantiate Connection obj
...
}
...
any suggestions?
[1044 byte] By [
dfundaka] at [2007-11-27 11:09:30]

# 2
Hi georgemc.
I'm trying to load driver like this
try {
URL ora8libURL = new URL("file:///C:/oracle/product/10.2.0/clientDev/jdbc/lib/classes12.jar");
Class.forName("oracle.jdbc.OracleDriver", true, URLClassLoader.newInstance(new URL[]{ora8libURL}));
conn = DriverManager.getConnection("jdbc:oracle:thin:@//192.168.186.13:1521/rdb817","user","password");
}
catch(ClassNotFoundException ex) {ex.printStackTrace();}
catch(MalformedURLException ex) {ex.printStackTrace();}
catch (SQLException ex) {ex.printStackTrace();}
but i've got this error:
java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@//192.168.186.13:1521/rdb817
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
However, when i specify driver explicit i works fine.
Message was edited by:
dfundak