Search code examples
javaspringspring-bootderby

Where is the Derby embedded driver?


I have a Spring Boot project with Gradle that I want to use Derby for. I have the following jars included here (I should only need the first, but I'm trying the second too):

implementation("org.apache.derby:derby:10.15.2.0")
implementation("org.apache.derby:derbyclient:10.15.2.0")

This actually gives me 3 jars (including the tools) and none have the EmbeddedDriver that Spring wants. What gives?

spring.datasource.url=jdbc:derby:/tmp/nhsta_derby;create=true
Property: driver-class-name
    Value: org.apache.derby.jdbc.EmbeddedDriver
    Origin: "driverClassName" from property source "source"
    Reason: Failed to load driver class org.apache.derby.jdbc.EmbeddedDriver in either of HikariConfig class loader or Thread context classloader

This finds nothing:

find ~/.gradle/caches/ -name 'derby*.jar' -exec jar -tf {} \; | grep EmbeddedDriver


Solution

  • Spring Boot doesn't support Derby 10.15 as it requires Java 9 or later and Spring Boot currently supports Java 8 and later. If you allow Spring Boot's dependency management to control the version (by omitting the version when you declare the dependency), you'll use 10.14 where the org.apache.derby:derby module contains the expected EmbeddedDriver class:

    implementation("org.apache.derby:derby")