jdbc - H2 显示 DB_CLOSE DELAY 的值(由 SET DB_CLOSE_DELAY 设置)
问题描述
H2 数据库有一个以 SET 开头的命令列表,特别是 SET DB_CLOSE_DELAY。我想知道 DB_CLOSE_DELAY 的值是多少。我正在使用 JDBC。设置简单
cx.createStatement.execute("SET DB_CLOSE_DELAY 0")
但以下均不返回 DB_CLOSE_DELAY 的实际值:
cx.createStatement.executeQuery("DB_CLOSE_DELAY")
cx.createStatement.executeQuery("VALUES(@DB_CLOSE_DELAY)")
cx.createStatement.executeQuery("GET DB_CLOSE_DELAY")
cx.createStatement.executeQuery("SHOW DB_CLOSE_DELAY")
帮助将不胜感激。
解决方案
您可以访问INFORMATION_SCHEMA.SETTINGS
表中的此设置和其他设置 - 例如:
String url = "jdbc:h2:mem:;DB_CLOSE_DELAY=3";
Connection conn = DriverManager.getConnection(url, "sa", "the password goes here");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM INFORMATION_SCHEMA.SETTINGS where name = 'DB_CLOSE_DELAY'");
while (rs.next()) {
System.out.println(rs.getString("name"));
System.out.println(rs.getString("value"));
}
在这个测试中,我使用了一个未命名的内存数据库,并3
在创建数据库时将延迟显式设置为秒。
打印语句的输出是:
DB_CLOSE_DELAY
3
推荐阅读
- python - 转换 Twilio 双向
媒体有效负载到 Python 中的 .wav 文件 - flutter - 不同路由 Flutter 中的 Provider
- reactjs - 打字稿反应图像src要求产生错误找不到模块
- static-analysis - Frama-C - 通过命令行获取函数输入值
- mongodb - 使用 id 字段的值更新 mongodb 集合的所有字段
- laravel - 我想在页面过期(419)显示时重定向到登录页面
- javascript - 如何从 VueJS 应用程序 ping IP 地址?
- python - 如何使用 python 获取字典中文件的内容?
- layout - 如何使相同等级的节点的点更宽?
- python - Pandas 中每个用户名的并发事件数