问题
I have a Java Derby database running in Netbeans and I'm trying to connect to it using the JDBC driver. However, I cannot import the JDBC driver specifically from the org.apache.derby package.
What I've done:
My pom.xml file contains the following Maven repo's
<!-- https://mvnrepository.com/artifact/org.apache.derby/derby --> <dependency> <groupId>org.apache.derby</groupId> <artifactId>derby</artifactId> <version>10.15.1.3</version> <type>jar</type> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.derby/derbyclient --> <dependency> <groupId>org.apache.derby</groupId> <artifactId>derbyclient</artifactId> <version>10.15.1.3</version> </dependency> <dependency> <groupId>org.apache.derby</groupId> <artifactId>derbynet</artifactId> <version>10.15.1.3</version> </dependency>
The Derby db properties says the database is using the driver as you can see here
When trying to import the JDBC driver, it is seemingly the only thing missing from the derby import list shown in this screenshot
I have also downloaded the derby.jar file and copied it directly into C:\Program Files\Java\jdk8-221\bin
I really can't understand why the JDBC driver specifically is missing.
回答1:
I see that you are using release 10.15. In this release, the arrangement of the Derby distribution into jar files has changed, and this is probably affecting you.
Please read the 10.15 Release Notes very carefully, and in particular please carefully look at the section "Note for DERBY-6945" for the details of how you have to change your classpath to access the Derby JDBC driver classes.
Probably, all you have to do is to include derbyshared.jar
. But please read the entire thing.
来源:https://stackoverflow.com/questions/58571355/i-cant-import-the-jdbc-client-driver-from-the-derby-package