I’m working on some software that sometimes needs to connect to an oracle 8.1.7 database, and sometimes to an oracle 10g database in order to perform some queries.
When connecting to the 8.1.7 database I need to use the ojdbc14.jar drivers, and the ojdbc6.jar drivers for the 10g database.
It seems that the automatic driver selection isn’t smart enough to select the correct driver when both of these drivers are in the classpath, is there any way that I can specify which one is preferred in my code?
I’m not currently using any connection pool or similar abstractions, but it wouldn’t be a problem to introduce something like that if needed.
If you are not using dbcp then you can do it like this
Note that ojdbc15.jar and ojdbc6.jar should not be on java classpath, they should be invisible for application classloader