I see two different solutions for different constellations.
(Using the same (?) Classes with different versions would usually be ideal for OSGi , or if your application is NetBeans RCP, their modular system. It works using class loaders that separate the software from the modules, so one of the different modules can load different banks with different versions of the same product.)
(Alternatively, you can use another application with its own Oracle kernel, accessed through RMI .)
You can use the same method: either write your own ClassLoader delegation, which loads the correct jar, or uses a conceptually simpler RMI which, however, requires system resource management.
So,
Choosing a ClassLoader Solution:
It is best to make your own delegation driver with the jdbc:myswitch:8: ... protocol. Then it can use two different instances of the loader class. For example, using a URLClassLoader with a file:/... path.
You can create two separate instances of the custom delegation driver so that you can use the delegation template.
public static class MySwitchDriver implements Driver { private final String oraURIPrefix; private final Driver delegateDriver; public MySwitchDriver(String oraURIPrefix) { this.oraURIPrefix = oraURIPrefix;
source share