我需要从 Vert.x 的 SQLConnection 中获取底层的 java.sql.Connection
I need to get the underlying java.sql.Connection from Vert.x's SQLConnection
我正在使用 vert.x 的 JDBCClient 获取我的数据库连接,它只给我 io.vertx.ext.sql.SQLConnection 或 io.vertx.reactivex.ext.sql.SQLConnection,其中 none 扩展 java.sql.Connection.
为了从 Verticle 调用 Liquibase,我需要一个 java.sql.Connection。
我知道 Vert.x 在后面使用 C3Po,但我找不到任何可以给我底层连接的方法。
我怎样才能做到这一点?
你试过吗:
final JDBCClient dbClient = JDBCClient.createShared(vertx, new JsonObject()
.put("url", dbUrl)
.put("user", user)
.put("password", pass)
.put("driver_class", "you.driver")
.put("max_pool_size", 30)
);
如果您使用的是最新版本,SQLConnection
有一个 unwrap
方法。如docs中所示:
default <N> N unwrap()
Return the underlying Connection object if available. This is not mandated to be implemented by the clients.
JDBCClient 应该return一个java.sql.Connection
。不要忘记在使用后对原始 SQLConnection
调用 close
。
我正在使用 vert.x 的 JDBCClient 获取我的数据库连接,它只给我 io.vertx.ext.sql.SQLConnection 或 io.vertx.reactivex.ext.sql.SQLConnection,其中 none 扩展 java.sql.Connection.
为了从 Verticle 调用 Liquibase,我需要一个 java.sql.Connection。
我知道 Vert.x 在后面使用 C3Po,但我找不到任何可以给我底层连接的方法。
我怎样才能做到这一点?
你试过吗:
final JDBCClient dbClient = JDBCClient.createShared(vertx, new JsonObject()
.put("url", dbUrl)
.put("user", user)
.put("password", pass)
.put("driver_class", "you.driver")
.put("max_pool_size", 30)
);
如果您使用的是最新版本,SQLConnection
有一个 unwrap
方法。如docs中所示:
default <N> N unwrap()
Return the underlying Connection object if available. This is not mandated to be implemented by the clients.
JDBCClient 应该return一个java.sql.Connection
。不要忘记在使用后对原始 SQLConnection
调用 close
。