Using connections
When you need to execute sequential queries (without a transaction), you can create a new connection or borrow one from the pool:
Code not translatable
Prepared queries can be created:
var Tuple = require("vertx-sql-client-js/tuple");
connection.prepare("SELECT * FROM users WHERE first_name LIKE ?", function (ar1, ar1_err) {
if (ar1_err == null) {
var prepared = ar1;
prepared.query().execute(Tuple.of("julien"), function (ar2, ar2_err) {
if (ar2_err == null) {
// All rows
var rows = ar2;
}
});
}
});
|
Note
|
prepared query caching depends on the cachePreparedStatements and
does not depend on whether you are creating prepared queries or use direct prepared queries
|
`link:../../jsdoc/module-vertx-sql-client-js_prepared_statement-PreparedStatement.html[can perform efficient batching:
{@link examples.SqlClientExamples#usingConnections03(io.vertx.sqlclient.SqlConnection)]`