Class JdbcUserDirectory.AbstractJdbcQueryExecutor<T>
java.lang.Object
org.ametys.plugins.core.impl.user.directory.JdbcUserDirectory.AbstractJdbcQueryExecutor<T>
- Type Parameters:
T
- The type of the queried object
- Direct Known Subclasses:
JdbcUserDirectory.SelectUserJdbcQueryExecutor
,JdbcUserDirectory.SelectUsersJdbcQueryExecutor
- Enclosing class:
- JdbcUserDirectory
An internal query executor.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected ResultSet
Execute the prepared statement and retrieves the result set.protected abstract String
getSqlQuery
(Connection connection) Must return the SQL query to executeprotected PreparedStatement
prepareStatement
(Connection connection, String sql) Prepare the statement to executeprotected T
Process the result setrun()
Main function, run the query process.Main function, run the query process.
-
Constructor Details
-
AbstractJdbcQueryExecutor
protected AbstractJdbcQueryExecutor()
-
-
Method Details
-
run
Main function, run the query process. Will not throw exception. Use runWithException to catch non SQL exception thrown byprocessResultSet(ResultSet)
- Returns:
- The queried object or null
-
runWithException
Main function, run the query process.- Returns:
- The queried object or null
- Throws:
Exception
- All non SQLException will be thrown
-
getSqlQuery
Must return the SQL query to execute- Parameters:
connection
- The pool connection- Returns:
- The SQL query
-
prepareStatement
Prepare the statement to execute- Parameters:
connection
- The pool connectionsql
- The SQL query- Returns:
- The prepared statement, ready to be executed
- Throws:
SQLException
- If an SQL Exception occurs
-
executeQuery
Execute the prepared statement and retrieves the result set.- Parameters:
stmt
- The prepared statement- Returns:
- The result set
- Throws:
SQLException
- If an SQL Exception occurs
-
processResultSet
Process the result set- Parameters:
rs
- The result set- Returns:
- The queried object or null
- Throws:
SQLException
- If an SQL exception occursException
- Other exception will be thrown when usingrunWithException()
-