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
protected abstract class JdbcUserDirectory.AbstractJdbcQueryExecutor<T> extends Object
An internal query executor.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractJdbcQueryExecutor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected ResultSet
executeQuery(PreparedStatement stmt)
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
processResultSet(ResultSet rs)
Process the result setT
run()
Main function, run the query process.T
runWithException()
Main function, run the query process.
-
-
-
Constructor Detail
-
AbstractJdbcQueryExecutor
protected AbstractJdbcQueryExecutor()
-
-
Method Detail
-
run
public T 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
public T runWithException() throws Exception
Main function, run the query process.- Returns:
- The queried object or null
- Throws:
Exception
- All non SQLException will be thrown
-
getSqlQuery
protected abstract String getSqlQuery(Connection connection)
Must return the SQL query to execute- Parameters:
connection
- The pool connection- Returns:
- The SQL query
-
prepareStatement
protected PreparedStatement prepareStatement(Connection connection, String sql) throws SQLException
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
protected ResultSet executeQuery(PreparedStatement stmt) throws SQLException
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
protected T processResultSet(ResultSet rs) throws SQLException, Exception
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()
-
-