【发布时间】:2020-07-03 13:08:22
【问题描述】:
我无法处理 vertx-jdbc-client - 3.3.9 上的 JDBCClient 连接失败的情况,例如:没有要路由的主机、连接超时等。因为方法 .getConnection() 不返回 failedFuture 和即使在错误的主机名、用户名和密码上也不会调用 failed。
只有为连接提供的所有参数都有效时,该方法才会成功执行,否则代码块会卡住并且永远不会调用 SQLConnection。在我的情况下,即使使用 try catch 块包装代码也不会出错。
JDBCClient client = JDBCClient.createNonShared(Holder.getInstance().getVertx(), databaseConfig);
client.getConnection(connect -> {
if (connect.failed()){
client.close();
return;
}
/* Create connection on success */
SQLConnection connection = connect.result();
/* Execute Query */
相关:Vertx connection timeout not catched JDBCClient (.getConnection)
【问题讨论】: