2

I'm using vert.x's JDBCClient to get my database connections and it only gives me io.vertx.ext.sql.SQLConnection or io.vertx.reactivex.ext.sql.SQLConnection and none of them extends java.sql.Connection.

In order to call Liquibase from a verticle I need a java.sql.Connection.

I know that Vert.x uses C3Po on behind but I was not able to find any method that could give me the underlying connection.

How can I achieve that ?

Cristiano
  • 1,414
  • 15
  • 22

2 Answers2

4

If you're on a recent version, SQLConnection has an unwrap method. As indicated in the docs:

default <N> N unwrap()

Return the underlying Connection object if available. This is not mandated to be implemented by the clients.

The JDBCClient should return a java.sql.Connection. Don't forget to call close on the original SQLConnection after usage.

Community
  • 1
  • 1
tsegismont
  • 8,591
  • 1
  • 17
  • 27
-1

Have you tried with:

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)
    );