Closed xiaobaojiang closed 6 years ago
String sql = " select * from users where uid = ? and name = ? " ; JsonArray params = new JsonArray().add(1) ; // just one paramter. conn.queryWithParams( sql, params, res-> {} );
If params length can't match sql ? placeholder , the postgres-async drive will throw new InsufficientParametersException(holder.paramsCount, values), and conn.queryWithParams() can't catch the exception , it will always pending. and if postgresql-async drive throw other exception , it will alse peding .
I suggest use Future instead of callback way , because Future can avoid the unexpected exception
Future.<Void>future(future -> beginTransactionIfNeeded(future.completer())) .compose(success -> { Future<ResultSet> future1 = Future.future(); final scala.concurrent.Future<QueryResult> future = connection.sendPreparedStatement(sql, ScalaUtils.toScalaList(params.getList())); future.onComplete(ScalaUtils.toFunction1(handleAsyncQueryResultToResultSet(future1)), executionContext); return future1; }) .setHandler(res -> { handler.handle(res); }); return this;
If params length can't match sql ? placeholder , the postgres-async drive will throw new InsufficientParametersException(holder.paramsCount, values), and conn.queryWithParams() can't catch the exception , it will always pending. and if postgresql-async drive throw other exception , it will alse peding .
I suggest use Future instead of callback way , because Future can avoid the unexpected exception