Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用 JDBC 连接到 Oracle 数据库。应用程序运行很长时间。所以我需要如果连接没有被服务器关闭,没有发生网络断开等。我应该运行小查询还是以其他方式存在?使用 isValid 我不能,因为 jdbc 驱动程序不支持。
运行一个简单的查询,比如
SELECT 1 FROM dual
是最万无一失的方法。这就是大多数 Java EE 应用服务器为验证来自其连接池的连接是否仍处于活动状态而执行的操作。