Java 开发集成 Derby 问题:连接到端口 1,527 上的服务器 localhost 时出错,消息为 Connection refused: connect。
·
String dbURL = "jdbc:derby://localhost:1527/mydb;create=true";
try (Connection connection = DriverManager.getConnection(dbURL)) {
System.out.println("连接 Derby 成功");
...
} catch (SQLException e) {
e.printStackTrace();
}
- 在 Java 开发中(Java 17),集成 Derby,执行上述代码时,出现如下错误信息
java.sql.SQLNonTransientConnectionException: java.net.ConnectException:连接到端口 1,527 上的服务器 localhost 时出错,消息为 Connection refused: connect。
问题原因
- 这个错误信息表示 Java 应用程序无法连接到数据库,通常是 Derby 数据库没有运行
处理策略
- 在 Windows 系统上,运行 Derby 根目录下的 bin 目录下的
startNetworkServer.bat
更多推荐


所有评论(0)