我目前正在使用JDBCPool
DAO,似乎连接级别没有超时选项。此选项的用例是,有时我正在查询的表被锁定,并且我正在使用的任何查询(选择或更新)io.vertx.sqlclient.SQLConnection
都会进入无限等待并且不会触发超时。
我检查了JDBCPool和SQLConnection的 API 文档,但没有提供任何选项。
但我可以看到io.vertx.ext.sql.SQLConnection的选项。为什么没有为池连接提供相同的选项?
下面是我正在使用的代码,
初始化池
pool = JDBCPool.pool(vertx, new JDBCDriver().dbConfigBuild(dbConfigObj));
pool.getConnection(con -> {
if (con.succeeded()) {
使用池执行查询
pool.query(query).execute(rowSetAsyncResult -> {
if (rowSetAsyncResult.succeeded()) {
logger.info("Query executed successfully"); //not printed in log
} else {
logger.error("Query failed"); //not printed in log
}
查询后,执行不会成功或失败,它只是等待执行。
如何在连接或语句对象中为查询执行添加超时。