On 26/05/2024 21:35, Pierre Vacher wrote:
> With the versions preceding version 6, if you dont use embedded mode,
> you dont need the native jar archive and you can dynamically load the
> driver of your choice at the time of connection. The jdbcDriverOOo
> driver allows you to specify the path of the jar archive and the class
> of the driver in the connection properties *JavaDriverClassPath* and
> *JavaDriverClass* respectively.
> Loading drivers is done with Class.forName() with an URL classloader in
> DriverBase.registerDriver()
> <
https://github.com/prrvchr/jdbcDriverOOo/blob/master/source/jdbcDriverOOo/source/io/github/prrvchr/uno/sdbc/DriverBase.java#L299> method.
I think you need to pass the URLs of both JARs and their dependencies
(like jna-jpms) to the `URLClassLoader`
> I am not sure what you mean with "The Java services are used
> recursively
> between these two archives".
>
>
> That's not really accurate. What it seems to me is that jaybird obtains
> the implementation of embedded mode in the native jar archive via java
> services, and that the native archive de facto considers that the
> jaybird archive is in the classpath while it would be more judicious to
> go through a factory.
This is the standard way of loading service providers in Java. The
native and embedded implementations are "plugins"/service providers.
They would always have a dependency on the main JAR because they extend
classes and implement interfaces from the main JAR.
> Le dimanche 26 mai 2024 à 20:08:10 UTC+2, Mark Rotteveel a écrit :
>
> Jaybird itself loads classes implementing the interface
> GDSFactoryPlugin, which are provided by WireGDSFactoryPlugin,
> NativeGDSFactoryPlugin, and EmbeddedGDSFactoryPlugin, all three of
> which
> extend the abstract class BaseGDSFactoryPlugin for their common
> implementation. Those last two are in jaybird-native in Jaybird 6.
>
> With versions previous to version 6, if we do not use embedded mode, we
> only need the jaybird archive and we are able to load the driver with a
> Class.forName and a URL classloader and without the need to put the
> archive in the classpath. Using embedded mode requires the use of the
> native archive and using the native archive requires putting jaybird in
> the classpath.
>
> Le dimanche 26 mai 2024 à 20:10:25 UTC+2, Mark Rotteveel a écrit :
>
> The problem you're having is unclear to me. Please provide more
> details,
> and show how you load Jaybird and especially how you handle loading the
> JAR files.
>
>
> If I can no longer use Class.forName with a URL classloader then the
> connection options allowing you to specify the driver (path and class)
> to load are no longer usable.
You can still do that, but - at a guess - you need pass *all*
dependencies to that URL classloader (that is why it accepts an array!).
That said, it has been a while since I worked with URLClassLoader and
composite class loader hierarchies, so I might be wrong there.
Alternatively, you need to build a fat JAR that merges both JARs into a
single JAR, but I would very much advise against that.
That said, I would expect you to have similar problems with Derby as
that driver is also split into multiple JARs?
Mark
--
Mark Rotteveel