Class StatementBuilder
java.lang.Object
me.hsgamer.hscore.database.client.sql.StatementBuilder
The
PreparedStatement
builder-
Method Summary
Modifier and TypeMethodDescriptionAdd values to the statementAdd values to the statementvoid
consume
(ResultSetConsumer consumer) Query from the connection and consume the result setvoid
consumeSafe
(ResultSetConsumer consumer) Query from the connection and consume the result set, but ignores exceptionsstatic StatementBuilder
create
(Connection connection) Create a new builder for the connection<T> T
execute
(SqlExecutor<T> sqlExecutor) Execute the statementGet the connectionGet the statementGet the values<T> T
query
(ResultSetConverter<T> converter) Query from the connection and convert to the final object<T> Optional<T>
querySafe
(ResultSetConverter<T> converter) Query from the connection and convert to the final object, but ignores exceptionssetStatement
(String statement) Set the statement to executeint
update()
Update the databaseint
Update the database but ignores exceptions
-
Method Details
-
create
Create a new builder for the connection- Parameters:
connection
- the connection- Returns:
- the builder
-
addValues
Add values to the statement- Parameters:
values
- the values- Returns:
- the builder for chaining
-
addValues
Add values to the statement- Parameters:
values
- the values- Returns:
- the builder for chaining
-
execute
Execute the statement- Type Parameters:
T
- the type of the result- Parameters:
sqlExecutor
- the executor- Returns:
- the result
- Throws:
SQLException
- if there is an SQL error
-
query
Query from the connection and convert to the final object- Type Parameters:
T
- the type of the final object- Parameters:
converter
- the converter- Returns:
- the final object
- Throws:
SQLException
- if there is an SQL error
-
consume
Query from the connection and consume the result set- Parameters:
consumer
- the consumer- Throws:
SQLException
- if there is an SQL error
-
update
Update the database- Returns:
- the row count or 0 for nothing
- Throws:
SQLException
- if there is an SQL error
-
querySafe
Query from the connection and convert to the final object, but ignores exceptions- Type Parameters:
T
- the type of the final object- Parameters:
converter
- the converter- Returns:
- the final object
-
consumeSafe
Query from the connection and consume the result set, but ignores exceptions- Parameters:
consumer
- the consumer
-
updateSafe
public int updateSafe()Update the database but ignores exceptions- Returns:
- the row count or 0 for nothing
-
getConnection
Get the connection- Returns:
- the connection
-
getStatement
Get the statement- Returns:
- the statement
-
setStatement
Set the statement to execute- Parameters:
statement
- the statement- Returns:
- the builder for chaining
-
getValues
Get the values- Returns:
- the values
-