java.lang.Object
org.seppiko.commons.utils.jdbc.SQLExecutor
SQL executor
- Author:
- Leonard Woo
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close ConnectionintExecuteINSERTUPDATEDELETEor other statementintExecuteINSERTUPDATEDELETEor other statementlongExecuteINSERTUPDATEDELETEor other statementlongexecuteWithGeneratedKey(String sql, Object... params) ExecuteINSERTUPDATEDELETEor other statementQuery ExecuteSELECTstatementQuery ExecuteSELECTstatement
-
Constructor Details
-
SQLExecutor
Initialize SQL executor- Parameters:
conn- the connection.- Throws:
NullPointerException- connection is null
-
-
Method Details
-
query
Query ExecuteSELECTstatement- Parameters:
sql- SQL Statement.- Returns:
- a
ResultSetobject that contains the data produced by the given query; nevernull - Throws:
SQLException- if a database access error occurs.IllegalArgumentException- SQL is empty or null.
-
query
Query ExecuteSELECTstatement- Parameters:
sql- SQL Statement.params- parameters.- Returns:
- a
ResultSetobject that contains the data produced by the given query; nevernull - Throws:
SQLException- if a database access error occurs.IllegalArgumentException- SQL is empty or null.
-
execute
ExecuteINSERTUPDATEDELETEor other statement- Parameters:
sql- SQL Statement.- Returns:
- SQL execute row count.
- Throws:
SQLException- if a database access error occurs.IllegalArgumentException- SQL is empty or null.
-
execute
ExecuteINSERTUPDATEDELETEor other statement- Parameters:
sql- SQL Statement.params- parameters.- Returns:
- SQL execute row count.
- Throws:
SQLException- if a database access error occurs.IllegalArgumentException- SQL is empty or null.
-
executeWithGeneratedKey
ExecuteINSERTUPDATEDELETEor other statement- Parameters:
sql- SQL Statement.- Returns:
- auto-generated key, -1 is Fail, and 0 is not get key.
- Throws:
SQLException- if a database access error occurs.IllegalArgumentException- SQL is empty or null.
-
executeWithGeneratedKey
public long executeWithGeneratedKey(String sql, Object... params) throws SQLException, IllegalArgumentException ExecuteINSERTUPDATEDELETEor other statement- Parameters:
sql- SQL Statement.params- parameters.- Returns:
- auto-generated key, -1 is Fail, and 0 is not get key.
- Throws:
SQLException- if a database access error occurs.IllegalArgumentException- SQL is empty or null.
-
close
Close Connection- Throws:
SQLException- if a database access error occurs.
-