注册
Java连库卡死
专栏/培训园地/ 文章详情 /

Java连库卡死

爱新觉罗·bingo 2024/07/19 1032 2 1
摘要

java代码连库卡死,哪位遇到帮分析下?

System.out.printf("-------------- start connection db-------%s--------%n", dbInfo.getDesc());
卡死在这一行,代码不再向下走
try (Connection connection = DriverManager.getConnection(dbInfo.getUrl(), dbInfo.getUser(), dbInfo.getPwd())😉 {
System.out.printf("%s:connection db success!!!%n", dbInfo.getDesc());
out.println("数据库连接成功");
// 创建一个简单的查询
Statement statement = connection.createStatement();
statement.execute("SELECT 1");
System.out.printf("%s:query db success!!!%n", dbInfo.getDesc());
out.println("测试查询成功");
} catch (SQLException e) {
System.out.printf("%s:数据库连接或查询失败 %s %n", dbInfo.getDesc(), e.getMessage());
// e.printStackTrace();
out.println("数据库连接或查询失败: " + e.getMessage());
}

增加额DriverManager得日志输出,卡在这里
[2024-07-16 10:22:57] [INFO] [System.out] [ skipping: java.sql.DriverInfo
]
[2024-07-16 10:22:57] [INFO] [System.out] [ skipping: java.sql.DriverInfo
]
[2024-07-16 10:22:57] [INFO] [System.out] [ trying dm.jdbc.driver.DmDriver

评论
后发表回复

作者

文章

阅读量

获赞

扫一扫
联系客服