簡體   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