vert-x / mod-mysql-postgresql

Vert.x 2.x is deprecated - use instead
http://vertx.io/docs/vertx-mysql-postgresql-client/java/
Apache License 2.0
49 stars 17 forks source link

Readme improvement - prepared action #33

Closed gitplaneta closed 10 years ago

gitplaneta commented 10 years ago

I've added this change to readme, because there's an unpleasant exception when using prepared statements for raw queries with no input arguments. Maybe the "values" should be an optional parameter?

For example, this causes problems when commented 'values':

    vertx.createHttpServer().requestHandler(req -> {

        JsonObject json = new JsonObject();
        json.putString("action", "prepared");
        json.putString("statement", "SELECT * FROM assetlink");
        //json.putArray("values", new JsonArray());

        vertx.eventBus().send("sql-executor", json, (Message<JsonObject> msg) -> {
            req.response().end(msg.body().encode());
        });
    }).listen(8080);

exception: "io.vertx.asyncsql.database.ConnectionHandler$$anonfun$prepared$1.apply(ConnectionHandler.scala:123) io.vertx.asyncsql.database.ConnectionHandler$$anonfun$prepared$1.apply(ConnectionHandler.scala:122) io.vertx.asyncsql.database.ConnectionHandler$$anonfun$sendWithPool$1.apply(ConnectionHandler.scala:114) io.vertx.asyncsql.database.ConnectionHandler$$anonfun$sendWithPool$1.apply(ConnectionHandler.scala:113) io.vertx.asyncsql.database.pool.AsyncConnectionPool$$anonfun$withConnection$2.apply(AsyncConnectionPool.scala:84) io.vertx.asyncsql.database.pool.AsyncConnectionPool$$anonfun$withConnection$2.apply(AsyncConnectionPool.scala:82) scala.util.Success$$anonfun$map$1.apply(Try.scala:206) scala.util.Try$.apply(Try.scala:161) scala.util.Success.map(Try.scala:206) scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:235) scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:235) scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32) org.vertx.scala.core.VertxExecutionContext$VertxExecutionContextImpl$$anonfun$execute$1.apply$mcV$sp(VertxExecutionContext.scala:49) org.vertx.scala.core.FunctionConverters$$anon$3.handle(FunctionConverters.scala:35) org.vertx.scala.core.FunctionConverters$$anon$3.handle(FunctionConverters.scala:34) org.vertx.java.core.impl.DefaultContext$2.run(DefaultContext.java:144) org.vertx.java.core.impl.DefaultContext$3.run(DefaultContext.java:175) io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354) io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:353) io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101) java.lang.Thread.run(Thread.java:745)"

Narigo commented 10 years ago

Thanks!