com.jenkov.mrpersister.impl
Class PreparedStatementManagerBase
java.lang.Object
com.jenkov.mrpersister.impl.PreparedStatementManagerBase
- All Implemented Interfaces:
- IPreparedStatementManager
public class PreparedStatementManagerBase
- extends java.lang.Object
- implements IPreparedStatementManager
- Author:
- Jakob Jenkov - Copyright 2005 Jenkov Development
Method Summary |
java.lang.Object |
execute(java.sql.PreparedStatement statement)
Executes the PreparedStatement. |
void |
init(java.sql.PreparedStatement statement)
Initializes the PreparedStatement. |
void |
postProcess(java.sql.PreparedStatement statement)
Post processes the PreparedStatement after execution. |
java.sql.PreparedStatement |
prepare(java.lang.String sql,
java.sql.Connection connection)
Returns a PreparedStatement prepared from the SQL and the connection. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
parameters
protected java.lang.Object[] parameters
isQuery
protected boolean isQuery
PreparedStatementManagerBase
public PreparedStatementManagerBase()
PreparedStatementManagerBase
public PreparedStatementManagerBase(java.lang.Object[] parameters)
prepare
public java.sql.PreparedStatement prepare(java.lang.String sql,
java.sql.Connection connection)
throws java.sql.SQLException,
PersistenceException
- Description copied from interface:
IPreparedStatementManager
- Returns a PreparedStatement prepared from the SQL and the connection.
Implement this method if the default implementation in PreparedStatementManagerBase
doesn't match your needs. For instance, if you need to call a different
Connection.prepare(...) method.
- Specified by:
prepare
in interface IPreparedStatementManager
- Parameters:
sql
- The SQL to prepare the PreparedStatement for.connection
- The connection to use to prepare the PreparedStatement.
- Returns:
- A PreparedStatement.
- Throws:
java.sql.SQLException
- If the preparation fails.
PersistenceException
- If something else goes wrong during the prepare method.
init
public void init(java.sql.PreparedStatement statement)
throws java.sql.SQLException,
PersistenceException
- Description copied from interface:
IPreparedStatementManager
- Initializes the PreparedStatement. Typicially this means setting the correct parameters
on the statement (setString(1, "value"), setLong(1, 45) etc.).
- Specified by:
init
in interface IPreparedStatementManager
- Parameters:
statement
- The PreparedStatement to initialize.
- Throws:
java.sql.SQLException
- If the initialization fails in the JDBC driver.
PersistenceException
- If something else goes wrong during initialization.
execute
public java.lang.Object execute(java.sql.PreparedStatement statement)
throws java.sql.SQLException,
PersistenceException
- Description copied from interface:
IPreparedStatementManager
- Executes the PreparedStatement.
- Specified by:
execute
in interface IPreparedStatementManager
- Parameters:
statement
- The PreparedStatement to execute.
- Returns:
- The result of the execute() method. For instance a ResultSet.
- Throws:
java.sql.SQLException
- If the executing fails.
PersistenceException
- If something else fails during execution.
postProcess
public void postProcess(java.sql.PreparedStatement statement)
throws java.sql.SQLException,
PersistenceException
- Description copied from interface:
IPreparedStatementManager
- Post processes the PreparedStatement after execution. Typically post processing
will be reading of generated id's. You do not need to close the PreparedStatement
in this method.
- Specified by:
postProcess
in interface IPreparedStatementManager
- Parameters:
statement
- The PreparedStatement to post process.
- Throws:
java.sql.SQLException
- If post processing fails in the driver.
PersistenceException
- If something else fails during post processing.