我在执行java应用程序时遇到以下错误:
Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:derby:flightdb;create=true
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:702)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:251)
at airline_reservation_system.Derby.<init>(Derby.java:19)
public Derby() throws SQLException {
databaseURL = "jdbc:derby:flightdb;create=true";
conn = DriverManager.getConnection(databaseURL);
statement = conn.createStatement();
createTables();
}
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.15.2.0</version>
<scope>test</scope>
</dependency>
package mwe;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class Derby {
private String databaseURL;
private Connection conn;
private Statement statement;
public static void main(String[] args) throws SQLException {
new Derby();
}
public Derby() throws SQLException {
databaseURL = "jdbc:derby:flightdb;create=true";
conn = DriverManager.getConnection(databaseURL);
statement = conn.createStatement();
}
}
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>code</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.9</maven.compiler.source>
<maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.derby/derbyclient -->
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.15.2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.derby/derby -->
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.15.2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
mvn依赖关系:树
mvn dependency:tree
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for groupId:code:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-compiler-plugin @ line 44, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ----------------------------< groupId:code >----------------------------
[INFO] Building code 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ code ---
[INFO] groupId:code:jar:1.0-SNAPSHOT
[INFO] +- org.apache.derby:derbyclient:jar:10.15.2.0:compile
[INFO] | \- org.apache.derby:derbyshared:jar:10.15.2.0:compile
[INFO] \- org.apache.derby:derby:jar:10.15.2.0:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.003 s
[INFO] Finished at: 2021-08-07T17:14:20+05:30
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.1.2.1</version>
</dependency>
可能对你有帮助
Class.forName("org.apache.derby.jdbc.ClientDriver"); // (for network)
Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); // (for embedded - afaicr)
就我个人而言,我在加载更高版本的驱动程序时遇到过问题。我很乐意得到指示;)我怀疑驱动程序加载的方式已经改变了更新:最新的是启用了JDBC4.0的自动加载。它用DriverManager.getConnection
加载ok
我刚开始使用Spring靴。我试图用apache derby创建一个REST API,将其作为嵌入式数据库,但我得到了以下错误: 商业服务: 实体类存储库: } 我没有在application.properties中定义任何内容。
这是我的代码: 有人能知道这段代码中的错误是什么,请修复它。
我正在尝试从我创建的一个简单的联系人表单中插入数据。我正在使用phpMyAdmin 下面是PHP(出于安全考虑,我删除了define语句,但我可以毫无问题地建立到数据库的链接。) 当有人点击论坛上的submit按钮后,代码就会运行,据我所知,这是正常工作的。 该错误发生在php代码的末尾。正在输出“SLQ Insert Statement FAILD”,但未发布mysql错误。 我的数据库/表的设
我正在构建一个将使用neo4j的web应用程序。我将在Java构建一个REST API,它将使用Neo4j嵌入式版本。这个架构有什么问题吗? 用别的方法好吗?Neo4j服务器? 谢谢!
我有一个Spring Boot和嵌入式Mongo DB的项目,我也想查找存储在那里的数据。我学习了本教程https://springframework.guru/spring-boot-with-embedd-mongoDB/
问题内容: 术语“嵌入式数据库”与“数据库”具有不同的含义吗? 问题答案: 我已经看到了嵌入式数据库的两个定义: 嵌入式数据库,例如专门为“嵌入式”空间(移动设备等)设计的数据库系统。这意味着它们在紧凑的环境中(在内存/ CPU方面)表现合理。 嵌入式数据库,就像不需要服务器的数据库一样,并且嵌入在应用程序中(例如SQLite)。这意味着所有内容都由应用程序管理。 我个人从未见过该术语完全按照Wi
我忙于一项学校作业,我有一个由三个表组成的基本access数据库。Book、Reader和BookRated,其中as BookRated是交集表,主键userName来自Reader和ISBN来自Book组成BookRated的复合主键(作为外键)。 我正试图将信息插入书签表中,但出现以下错误
问题内容: 我打算开发一个小型(Java)应用程序来管理我的财务。我相信我需要使用嵌入式数据库,但是我没有关于此问题的经验。我试图查看一些可用的产品,但是我无法确定哪种产品更适合我。H2,HSQLDB,Derby和Berkeley DB似乎是不错的候选者,但是我仍然看不到它们之间的比较。感谢您的比较,并帮助我决定使用哪个。 我打算将Hibernate用于我的应用程序(除非您建议使用DBMS提供的A