public interface SQLConnection extends SQLOperations, Closeable
Modifier and Type | Method and Description |
---|---|
SQLConnection |
batch(List<String> sqlStatements,
Handler<AsyncResult<List<Integer>>> handler)
Batch simple SQL strings and execute the batch where the async result contains a array of Integers.
|
SQLConnection |
batchCallableWithParams(String sqlStatement,
List<JsonArray> inArgs,
List<JsonArray> outArgs,
Handler<AsyncResult<List<Integer>>> handler)
Batch a callable statement with all entries from the args list.
|
SQLConnection |
batchWithParams(String sqlStatement,
List<JsonArray> args,
Handler<AsyncResult<List<Integer>>> handler)
Batch a prepared statement with all entries from the args list.
|
SQLConnection |
call(String sql,
Handler<AsyncResult<ResultSet>> resultHandler)
Calls the given SQL
PROCEDURE which returns the result from the procedure. |
SQLConnection |
callWithParams(String sql,
JsonArray params,
JsonArray outputs,
Handler<AsyncResult<ResultSet>> resultHandler)
Calls the given SQL
PROCEDURE which returns the result from the procedure. |
void |
close()
Closes the connection.
|
void |
close(Handler<AsyncResult<Void>> handler)
Closes the connection.
|
SQLConnection |
commit(Handler<AsyncResult<Void>> handler)
Commits all changes made since the previous commit/rollback.
|
SQLConnection |
execute(String sql,
Handler<AsyncResult<Void>> resultHandler)
Executes the given SQL statement
|
SQLConnection |
getTransactionIsolation(Handler<AsyncResult<TransactionIsolation>> handler)
Attempts to return the transaction isolation level for this Connection object to the one given.
|
SQLConnection |
query(String sql,
Handler<AsyncResult<ResultSet>> resultHandler)
Executes the given SQL
SELECT statement which returns the results of the query. |
SQLConnection |
queryStream(String sql,
Handler<AsyncResult<SQLRowStream>> handler)
Executes the given SQL
SELECT statement which returns the results of the query as a read stream. |
SQLConnection |
queryStreamWithParams(String sql,
JsonArray params,
Handler<AsyncResult<SQLRowStream>> handler)
Executes the given SQL
SELECT statement which returns the results of the query as a read stream. |
SQLConnection |
queryWithParams(String sql,
JsonArray params,
Handler<AsyncResult<ResultSet>> resultHandler)
Executes the given SQL
SELECT prepared statement which returns the results of the query. |
SQLConnection |
rollback(Handler<AsyncResult<Void>> handler)
Rolls back all changes made since the previous commit/rollback.
|
SQLConnection |
setAutoCommit(boolean autoCommit,
Handler<AsyncResult<Void>> resultHandler)
Sets the auto commit flag for this connection.
|
SQLConnection |
setOptions(SQLOptions options)
Sets the desired options to be applied to the current connection when statements are executed.
|
default SQLConnection |
setQueryTimeout(int timeoutInSeconds)
Deprecated.
instead use
setOptions(SQLOptions) with SQLOptions.setQueryTimeout(int) |
SQLConnection |
setTransactionIsolation(TransactionIsolation isolation,
Handler<AsyncResult<Void>> handler)
Attempts to change the transaction isolation level for this Connection object to the one given.
|
default <N> N |
unwrap()
Return the underlying Connection object if available.
|
SQLConnection |
update(String sql,
Handler<AsyncResult<UpdateResult>> resultHandler)
Executes the given SQL statement which may be an
INSERT , UPDATE , or DELETE
statement. |
SQLConnection |
updateWithParams(String sql,
JsonArray params,
Handler<AsyncResult<UpdateResult>> resultHandler)
Executes the given prepared statement which may be an
INSERT , UPDATE , or DELETE
statement with the given parameters |
querySingle, querySingleWithParams
SQLConnection setOptions(SQLOptions options)
options
- the options to modify the unwrapped connection.SQLConnection setAutoCommit(boolean autoCommit, Handler<AsyncResult<Void>> resultHandler)
autoCommit
- the autoCommit flag, true by default.resultHandler
- the handler which is called once this operation completes.Connection.setAutoCommit(boolean)
SQLConnection execute(String sql, Handler<AsyncResult<Void>> resultHandler)
sql
- the SQL to execute. For example CREATE TABLE IF EXISTS table ...
resultHandler
- the handler which is called once this operation completes.Statement.execute(String)
SQLConnection query(String sql, Handler<AsyncResult<ResultSet>> resultHandler)
SELECT
statement which returns the results of the query.query
in interface SQLOperations
sql
- the SQL to execute. For example SELECT * FROM table ...
.resultHandler
- the handler which is called once the operation completes. It will return a ResultSet
.Statement.executeQuery(String)
,
Statement.executeQuery(String)
SQLConnection queryStream(String sql, Handler<AsyncResult<SQLRowStream>> handler)
SELECT
statement which returns the results of the query as a read stream.queryStream
in interface SQLOperations
sql
- the SQL to execute. For example SELECT * FROM table ...
.handler
- the handler which is called once the operation completes. It will return a SQLRowStream
.Statement.executeQuery(String)
,
Statement.executeQuery(String)
SQLConnection queryWithParams(String sql, JsonArray params, Handler<AsyncResult<ResultSet>> resultHandler)
SELECT
prepared statement which returns the results of the query.queryWithParams
in interface SQLOperations
sql
- the SQL to execute. For example SELECT * FROM table ...
.params
- these are the parameters to fill the statement.resultHandler
- the handler which is called once the operation completes. It will return a ResultSet
.Statement.executeQuery(String)
,
Statement.executeQuery(String)
SQLConnection queryStreamWithParams(String sql, JsonArray params, Handler<AsyncResult<SQLRowStream>> handler)
SELECT
statement which returns the results of the query as a read stream.queryStreamWithParams
in interface SQLOperations
sql
- the SQL to execute. For example SELECT * FROM table ...
.params
- these are the parameters to fill the statement.handler
- the handler which is called once the operation completes. It will return a SQLRowStream
.Statement.executeQuery(String)
,
Statement.executeQuery(String)
SQLConnection update(String sql, Handler<AsyncResult<UpdateResult>> resultHandler)
INSERT
, UPDATE
, or DELETE
statement.update
in interface SQLOperations
sql
- the SQL to execute. For example INSERT INTO table ...
resultHandler
- the handler which is called once the operation completes.Statement.executeUpdate(String)
,
Statement.executeUpdate(String)
SQLConnection updateWithParams(String sql, JsonArray params, Handler<AsyncResult<UpdateResult>> resultHandler)
INSERT
, UPDATE
, or DELETE
statement with the given parametersupdateWithParams
in interface SQLOperations
sql
- the SQL to execute. For example INSERT INTO table ...
params
- these are the parameters to fill the statement.resultHandler
- the handler which is called once the operation completes.Statement.executeUpdate(String)
,
Statement.executeUpdate(String)
SQLConnection call(String sql, Handler<AsyncResult<ResultSet>> resultHandler)
PROCEDURE
which returns the result from the procedure.call
in interface SQLOperations
sql
- the SQL to execute. For example {call getEmpName}
.resultHandler
- the handler which is called once the operation completes. It will return a ResultSet
.Statement.execute(String)
SQLConnection callWithParams(String sql, JsonArray params, JsonArray outputs, Handler<AsyncResult<ResultSet>> resultHandler)
PROCEDURE
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:
params = [VALUE1, VALUE2, null] outputs = [null, null, "VARCHAR"]
callWithParams
in interface SQLOperations
sql
- the SQL to execute. For example {call getEmpName (?, ?)}
.params
- these are the parameters to fill the statement.outputs
- these are the outputs to fill the statement.resultHandler
- the handler which is called once the operation completes. It will return a ResultSet
.Statement.execute(String)
void close(Handler<AsyncResult<Void>> handler)
handler
- the handler called when this operation completes.void close()
close
in interface AutoCloseable
close
in interface Closeable
SQLConnection commit(Handler<AsyncResult<Void>> handler)
handler
- the handler called when this operation completes.SQLConnection rollback(Handler<AsyncResult<Void>> handler)
handler
- the handler called when this operation completes.@Deprecated default SQLConnection setQueryTimeout(int timeoutInSeconds)
setOptions(SQLOptions)
with SQLOptions.setQueryTimeout(int)
timeoutInSeconds
- the max amount of seconds the query can take to execute.SQLConnection batch(List<String> sqlStatements, Handler<AsyncResult<List<Integer>>> handler)
sqlStatements
- sql statementhandler
- the result handlerSQLConnection batchWithParams(String sqlStatement, List<JsonArray> args, Handler<AsyncResult<List<Integer>>> handler)
sqlStatement
- sql statementargs
- the prepared statement argumentshandler
- the result handlerSQLConnection batchCallableWithParams(String sqlStatement, List<JsonArray> inArgs, List<JsonArray> outArgs, Handler<AsyncResult<List<Integer>>> handler)
sqlStatement
- sql statementinArgs
- the callable statement input argumentsoutArgs
- the callable statement output argumentshandler
- the result handlerSQLConnection setTransactionIsolation(TransactionIsolation isolation, Handler<AsyncResult<Void>> handler)
isolation
- the level of isolationhandler
- the handler called when this operation completes.SQLConnection getTransactionIsolation(Handler<AsyncResult<TransactionIsolation>> handler)
handler
- the handler called when this operation completes.default <N> N unwrap()
N
- the underlying connection object typeCopyright © 2024 Eclipse. All rights reserved.