vertx-sql-client icon indicating copy to clipboard operation
vertx-sql-client copied to clipboard

Database is not selected

Open onthegit opened this issue 6 years ago • 6 comments

Hello,

vertx version : 4.0.0-milestone3 using vertx reactive mysql client simple code to reproduce: MySQLConnectOptions.setDatabase and use a connection pool to query simple SELECT statements returns "No database selected" error randomly on Pool.query() . I am guessing the database is not set for all the connections in the pool.

onthegit avatar Sep 24 '19 13:09 onthegit

5.5.60-MariaDB server

onthegit avatar Sep 24 '19 14:09 onthegit

Actually upon doing second test, it appears that the database is not set in any of the connections in the connection pool.

onthegit avatar Sep 24 '19 14:09 onthegit

I have just tested with a MariaDB 5.5.59 server and it works fine for me, can you provide more details?

BillyYccc avatar Sep 24 '19 15:09 BillyYccc

Here is the code I use: MySQLConnectOptions mc = new MySQLConnectOptions().setPort(3000).setHost("dbhost").setDatabase("database").setUser("user").setPassword("secret").setSslMode(SslMode.VERIFY_CA).setPemTrustOptions(new PemTrustOptions().addCertPath("/app/ca-cert.pem")).setCachePreparedStatements(false);

PoolOptions poolOptions = new PoolOptions().setMaxSize(5); MySQLPool _dbPool = MySQLPool.pool(vertx, mc, poolOptions);

for (int i = 0; i < 200; i++) { _dbPool.getConnection(r -> {

        if (r.succeeded()) {

            SqlConnection con = r.result();

            con.query(query, ar -> {

                con.close();

                if (ar.succeeded()) {

                    System.out.println("Got " + ar.result().size() + " rows ");
                    promise.complete(ar.result().size());
                } else {
                    System.out.println("Failure: " + ar.cause().getMessage());
                    promise.fail(ar.cause().getMessage());
                }
            });
        }
    });

}

If I run "Use database" sql before every query the database is selected and results are returned. Otherwise it just displays: Failure: No database selected No database selected

onthegit avatar Sep 24 '19 18:09 onthegit

The db server is on centos 7 linux, while vertx runs on Fedora 30.

onthegit avatar Sep 24 '19 18:09 onthegit

Is there a way to debug this?

onthegit avatar Sep 25 '19 20:09 onthegit