Hi Russell,
This is a little complicated because it involves a bit of history. Derby
and Java grew up together. The core of Derby is the Cloudscape database
engine, which appeared around 1996, close to the the appearance of Java
itself. Two significant events in the evolution of Java have affected
what happened to the Derby drivers. Where the code ended up is a little
weird, but the aim all along has been to minimize disruption to legacy
applications. The two events are:
1) The introduction of JDBC driver autoloading in Java 5 and the further
refinement of driver autoloading in Java 6.
2) The introduction of the JPMS module architecture in Java 9.
If you are getting connections via
java.sql.DriverManager.getConnection(), then you don't need to register
drivers at all. That is because the JVM will load all of the JDBC
drivers which are visible on the application classpath--that is, all of
the drivers which have metadata recorded in the manifests of their
respective jar files.
In Derby 10.15, the drivers around, in order to achieve the clean
package partitioning required by JPMS. The original embedded driver now
lives in the tools jar. The autoloading driver moved into another
package in the engine jar. It is now called
org.apache.derby.iapi.jdbc.AutoloadedDriver.
Hope this helps,
-Rick
On 7/7/20 6:00 PM, Russell Bateman wrote:
How do the myriad Derby drivers work?
I am using Apache Derby in-memory with no daemon or outside
dependencies in support of being called from JUnit tests. This is
working pretty well, but what it's going to be doing underneath will
eventually cause me to walk the following road, I think.
I am using 10.15.2.0. I find myself needing to register a driver such
that a call to DriverManager.getConnection()will find it. (Or, I think
I do; I'm looking at some existing homespun mocking code that does
this and I'm trying to imitate then replace it with Derby.)
DriverManager.registerDriver( new
org.apache.derby.jdbc.AutoLoadedDriver() );
Here and there, in examples on-line, I see references to drivers like:
org.apache.derby.jdbc.AutoloadedDriver
org.apache.derby.jdbc.EmbeddedDriver
However, unless I'm mistaken, these do not exist in derby 10.15.2.0. I
am using derby-10.15.2.0.jar. I have also tried adding the same
version's shared and tools JARs.
Any thoughts on this would help. I only discovered this phenomenon of
registering drivers today, so I'm stumbling around a bit.
Thanks.