繁体   English   中英

Apache Derby 10.15.* - java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver

[英]Apache Derby 10.15.* - java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver

While trying to use Apache Derby DB (aka JavaDB, being once part of JDK) as an embedded in-memory DB for tests, I've encountered ClassNotFoundException thrown by HikariCP not being able to instantiate org.apache.derby.jdbc.EmbeddedDriver .

该项目通过 Maven 建立。 德比依赖是:

<dependency>
    <artifactId>derby</artifactId>
    <groupId>org.apache.derby</groupId>
    <version>10.15.2.0</version>
    <scope>test</scope>
</dependency>

HikariCP 配置为:

HikariConfig config = new HikariConfig();
config.setDriverClassName("org.apache.derby.jdbc.EmbeddedDriver");
config.setJdbcUrl("jdbc:derby:memory:TestsDB;create=true");
return new HikariDataSource(config);

很少有线程提到ClientDriver ,但我确实需要EmbeddedDriver才能访问内存 JDBC。

有任何想法吗?

显然,事情从 Derby 版本10.14.*变为版本10.15.*

后者(我正在使用)在其 JAR 中确实没有这样的 class。

After some search in the sources I've found that org.apache.derby.jdbc.EmbeddedDriver has been moved to the tools JAR, so make sure to add the following dependency to your pom.xml too:

<dependency>
    <groupId>org.apache.derby</groupId>
    <artifactId>derbytools</artifactId>
    <version>10.15.2.0</version>
    <scope>test</scope>
</dependency>

注意:当然,调整这个工件的版本与主版本相同,不管你的情况是什么。

To Apache Derby guys: if this change is intent-full, I suggest to change the main Derby artifact description, which still misleadingly states "Contains the core Apache Derby database engine, which also includes the embedded JDBC driver " (emphasis is mine [YG ])。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM