/** * Returns a connection that can be used to perform SQL operations on. It's important to remember * to close the connection when you are done, so it is returned to the pool. * @param handler the handler which is called when the <code>JdbcConnection</code> object is ready for use. * @return */ public io.vertx.rxjava.ext.sql.SQLClient getConnection(Handler<AsyncResult<io.vertx.rxjava.ext.sql.SQLConnection>> handler) { delegate.getConnection(new Handler<AsyncResult<io.vertx.ext.sql.SQLConnection>>() { public void handle(AsyncResult<io.vertx.ext.sql.SQLConnection> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.ext.sql.SQLConnection.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
/** * Close the client */ public void close() { delegate.close(); }
/** * Calls the given SQL <code>PROCEDURE</code> which returns the result from the procedure. * * The index of params and outputs are important for both arrays, for example when dealing with a prodecure that * takes the first 2 arguments as input values and the 3 arg as an output then the arrays should be like: * * <pre> * params = [VALUE1, VALUE2, null] * outputs = [null, null, "VARCHAR"] * </pre> * @param sql the SQL to execute. For example <code>{call getEmpName (?, ?)}</code>. * @param params these are the parameters to fill the statement. * @param outputs these are the outputs to fill the statement. * @param handler the handler which is called once the operation completes. It will return a <code>ResultSet</code>. * @return */ public io.vertx.rxjava.ext.sql.SQLClient callWithParams(String sql, JsonArray params, JsonArray outputs, Handler<AsyncResult<ResultSet>> handler) { delegate.callWithParams(sql, params, outputs, handler); return this; }
private void showEncoding(TestContext context, String charSetString, Handler<String> encodingHandler) { client = createClient(vertx, new JsonObject() .put("charset", charSetString) ); client.getConnection(sqlConnectionAsyncResult -> { ensureSuccess(context, sqlConnectionAsyncResult); conn = sqlConnectionAsyncResult.result(); conn.query(getEncodingStatement(), showEncodingAr -> { ensureSuccess(context, showEncodingAr); String encoding = getEncodingValueFromResults(showEncodingAr.result().getResults()); conn.close(connCloseAr -> { ensureSuccess(context, connCloseAr); conn = null; client.close(clientCloseAr -> { ensureSuccess(context, clientCloseAr); client = null; encodingHandler.handle(encoding); }); }); }); }); }
/** * Execute a single SQL statement, this method acquires a connection from the the pool and executes the SQL * statement and returns it back after the execution. * @param sql the statement to execute * @param handler the result handler * @return self */ public io.vertx.rxjava.ext.sql.SQLClient query(String sql, Handler<AsyncResult<ResultSet>> handler) { delegate.query(sql, handler); return this; }
/** * Executes the given prepared statement which may be an <code>INSERT</code>, <code>UPDATE</code>, or <code>DELETE</code> * statement with the given parameters * @param sql the SQL to execute. For example <code>INSERT INTO table ...</code> * @param params these are the parameters to fill the statement. * @param handler the handler which is called once the operation completes. * @return */ public io.vertx.rxjava.ext.sql.SQLClient updateWithParams(String sql, JsonArray params, Handler<AsyncResult<UpdateResult>> handler) { delegate.updateWithParams(sql, params, handler); return this; }
/** * Execute a one shot SQL statement that returns a single SQL row. This method will reduce the boilerplate code by * getting a connection from the pool (this object) and return it back after the execution. Only the first result * from the result set is returned. * @param sql the statement to execute * @param handler the result handler * @return self */ public io.vertx.rxjava.ext.sql.SQLOperations querySingle(String sql, Handler<AsyncResult<JsonArray>> handler) { delegate.querySingle(sql, handler); return this; }
/** * Executes the given SQL <code>SELECT</code> statement which returns the results of the query as a read stream. * @param sql the SQL to execute. For example <code>SELECT * FROM table ...</code>. * @param handler the handler which is called once the operation completes. It will return a <code>SQLRowStream</code>. * @return */ public io.vertx.rxjava.ext.sql.SQLClient queryStream(String sql, Handler<AsyncResult<io.vertx.rxjava.ext.sql.SQLRowStream>> handler) { delegate.queryStream(sql, new Handler<AsyncResult<io.vertx.ext.sql.SQLRowStream>>() { public void handle(AsyncResult<io.vertx.ext.sql.SQLRowStream> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.ext.sql.SQLRowStream.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
/** * Calls the given SQL <code>PROCEDURE</code> which returns the result from the procedure. * @param sql the SQL to execute. For example <code>{call getEmpName}</code>. * @param handler the handler which is called once the operation completes. It will return a <code>ResultSet</code>. * @return */ public io.vertx.rxjava.ext.sql.SQLClient call(String sql, Handler<AsyncResult<ResultSet>> handler) { delegate.call(sql, handler); return this; }
/** * Execute a one shot SQL statement with arguments that returns a single SQL row. This method will reduce the * boilerplate code by getting a connection from the pool (this object) and return it back after the execution. * Only the first result from the result set is returned. * @param sql the statement to execute * @param arguments the arguments * @param handler the result handler * @return self */ public io.vertx.rxjava.ext.sql.SQLOperations querySingleWithParams(String sql, JsonArray arguments, Handler<AsyncResult<JsonArray>> handler) { delegate.querySingleWithParams(sql, arguments, handler); return this; }
private void showEncoding(TestContext context, String charSetString, Handler<String> encodingHandler) { client = createClient(vertx, new JsonObject() .put("charset", charSetString) ); client.getConnection(sqlConnectionAsyncResult -> { ensureSuccess(context, sqlConnectionAsyncResult); conn = sqlConnectionAsyncResult.result(); conn.query(getEncodingStatement(), showEncodingAr -> { ensureSuccess(context, showEncodingAr); String encoding = getEncodingValueFromResults(showEncodingAr.result().getResults()); conn.close(connCloseAr -> { ensureSuccess(context, connCloseAr); conn = null; client.close(clientCloseAr -> { ensureSuccess(context, clientCloseAr); client = null; encodingHandler.handle(encoding); }); }); }); }); }
/** * Execute a single SQL statement, this method acquires a connection from the the pool and executes the SQL * statement and returns it back after the execution. * @param sql the statement to execute * @param handler the result handler * @return self */ public io.vertx.rxjava.ext.sql.SQLClient query(String sql, Handler<AsyncResult<ResultSet>> handler) { delegate.query(sql, handler); return this; }
/** * Executes the given prepared statement which may be an <code>INSERT</code>, <code>UPDATE</code>, or <code>DELETE</code> * statement with the given parameters * @param sql the SQL to execute. For example <code>INSERT INTO table ...</code> * @param params these are the parameters to fill the statement. * @param handler the handler which is called once the operation completes. * @return */ public io.vertx.rxjava.ext.sql.SQLClient updateWithParams(String sql, JsonArray params, Handler<AsyncResult<UpdateResult>> handler) { delegate.updateWithParams(sql, params, handler); return this; }
/** * Execute a one shot SQL statement that returns a single SQL row. This method will reduce the boilerplate code by * getting a connection from the pool (this object) and return it back after the execution. Only the first result * from the result set is returned. * @param sql the statement to execute * @param handler the result handler * @return self */ public io.vertx.rxjava.ext.sql.SQLOperations querySingle(String sql, Handler<AsyncResult<JsonArray>> handler) { delegate.querySingle(sql, handler); return this; }
/** * Executes the given SQL <code>SELECT</code> statement which returns the results of the query as a read stream. * @param sql the SQL to execute. For example <code>SELECT * FROM table ...</code>. * @param handler the handler which is called once the operation completes. It will return a <code>SQLRowStream</code>. * @return */ public io.vertx.rxjava.ext.sql.SQLClient queryStream(String sql, Handler<AsyncResult<io.vertx.rxjava.ext.sql.SQLRowStream>> handler) { delegate.queryStream(sql, new Handler<AsyncResult<io.vertx.ext.sql.SQLRowStream>>() { public void handle(AsyncResult<io.vertx.ext.sql.SQLRowStream> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.ext.sql.SQLRowStream.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
/** * Calls the given SQL <code>PROCEDURE</code> which returns the result from the procedure. * @param sql the SQL to execute. For example <code>{call getEmpName}</code>. * @param handler the handler which is called once the operation completes. It will return a <code>ResultSet</code>. * @return */ public io.vertx.rxjava.ext.sql.SQLClient call(String sql, Handler<AsyncResult<ResultSet>> handler) { delegate.call(sql, handler); return this; }
/** * Execute a one shot SQL statement with arguments that returns a single SQL row. This method will reduce the * boilerplate code by getting a connection from the pool (this object) and return it back after the execution. * Only the first result from the result set is returned. * @param sql the statement to execute * @param arguments the arguments * @param handler the result handler * @return self */ public io.vertx.rxjava.ext.sql.SQLOperations querySingleWithParams(String sql, JsonArray arguments, Handler<AsyncResult<JsonArray>> handler) { delegate.querySingleWithParams(sql, arguments, handler); return this; }
/** * Returns a connection that can be used to perform SQL operations on. It's important to remember * to close the connection when you are done, so it is returned to the pool. * @param handler the handler which is called when the <code>JdbcConnection</code> object is ready for use. * @return */ public io.vertx.rxjava.ext.sql.SQLClient getConnection(Handler<AsyncResult<io.vertx.rxjava.ext.sql.SQLConnection>> handler) { delegate.getConnection(new Handler<AsyncResult<io.vertx.ext.sql.SQLConnection>>() { public void handle(AsyncResult<io.vertx.ext.sql.SQLConnection> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.ext.sql.SQLConnection.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
/** * Close the client and release all resources. * Call the handler when close is complete. * @param handler the handler that will be called when close is complete */ public void close(Handler<AsyncResult<Void>> handler) { delegate.close(handler); }
private void showEncoding(TestContext context, String charSetString, Handler<String> encodingHandler) { client = createClient(vertx, new JsonObject() .put("charset", charSetString) ); client.getConnection(sqlConnectionAsyncResult -> { ensureSuccess(context, sqlConnectionAsyncResult); conn = sqlConnectionAsyncResult.result(); conn.query(getEncodingStatement(), showEncodingAr -> { ensureSuccess(context, showEncodingAr); String encoding = getEncodingValueFromResults(showEncodingAr.result().getResults()); conn.close(connCloseAr -> { ensureSuccess(context, connCloseAr); conn = null; client.close(clientCloseAr -> { ensureSuccess(context, clientCloseAr); client = null; encodingHandler.handle(encoding); }); }); }); }); }