Class CastorStatement
- java.lang.Object
-
- org.castor.cpa.persistence.sql.engine.CastorStatement
-
public final class CastorStatement extends java.lang.Object
CastorStatement class to wrap handling of PreparedStatements by providing functionality to prepare statements, bind parameters, execute statements and, close statements.- Version:
- $Revision: 8469 $ $Date: 2006-04-25 15:08:23 -0600 (Tue, 25 Apr 2006) $
- Author:
- Dennis Butterstein, Ralf Joachim
-
-
Constructor Summary
Constructors Constructor Description CastorStatement(PersistenceFactory factory, java.sql.Connection connection)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bindParameter(java.lang.String name, java.lang.Object value, int type)
Method to bind passed parameters to the local statement.void
close()
Method to close the prepared statement.java.sql.ResultSet
executeQuery()
Method to execute prepared statement and return ResultSet.int
executeUpdate()
Method to execute prepared statement.int
getParameterSize()
Method returning size of the parameter map.java.sql.PreparedStatement
getStatement()
Method returning statement currently set.void
prepareStatement(Delete delete)
Method to prepare delete statement and store it in local Variable.void
prepareStatement(Insert insert)
Method to prepare insert statement and store it in local Variable.void
prepareStatement(Select select)
Method to prepare select statement and store it in local Variable.void
prepareStatement(Update update, Condition condition)
Method to prepare update statement, append passed condition and store it in local Variable.void
setStatement(java.sql.PreparedStatement stmt)
Method to set statement.java.lang.String
toString()
Method to get string representation of the existing query string.
-
-
-
Constructor Detail
-
CastorStatement
public CastorStatement(PersistenceFactory factory, java.sql.Connection connection)
Constructor.- Parameters:
factory
- Instance of PersistenceFactory to be used to create CastorStatements.connection
- Instance of the connection to be used to create CastorStatements.
-
-
Method Detail
-
getStatement
public java.sql.PreparedStatement getStatement()
Method returning statement currently set.- Returns:
- Statement currently set.
-
setStatement
public void setStatement(java.sql.PreparedStatement stmt)
Method to set statement.- Parameters:
stmt
- Statement to be set
-
getParameterSize
public int getParameterSize() throws java.sql.SQLException
Method returning size of the parameter map.- Returns:
- Size of the current parameter map of the QueryContext.
- Throws:
java.sql.SQLException
- Reports database access errors.
-
prepareStatement
public void prepareStatement(Select select) throws java.sql.SQLException
Method to prepare select statement and store it in local Variable.- Parameters:
select
- Prepared select-object to create statement for.- Throws:
java.sql.SQLException
- Reports database access errors.
-
prepareStatement
public void prepareStatement(Insert insert) throws java.sql.SQLException
Method to prepare insert statement and store it in local Variable.- Parameters:
insert
- Prepared insert-object to create statement for.- Throws:
java.sql.SQLException
- Reports database access errors.
-
prepareStatement
public void prepareStatement(Update update, Condition condition) throws java.sql.SQLException
Method to prepare update statement, append passed condition and store it in local Variable.- Parameters:
update
- Prepared update-object to create statement for.condition
- Condition to be appended to the QueryContext.- Throws:
java.sql.SQLException
- Reports database access errors.
-
prepareStatement
public void prepareStatement(Delete delete) throws java.sql.SQLException
Method to prepare delete statement and store it in local Variable.- Parameters:
delete
- Prepared delete-object to create statement for.- Throws:
java.sql.SQLException
- Reports database access errors.
-
bindParameter
public void bindParameter(java.lang.String name, java.lang.Object value, int type) throws java.sql.SQLException
Method to bind passed parameters to the local statement.- Parameters:
name
- Name of the parameter to be bound.value
- Value of the parameter to be bound.type
- Type of the parameter to be bound.- Throws:
java.sql.SQLException
- Reports database access errors.
-
executeUpdate
public int executeUpdate() throws java.sql.SQLException
Method to execute prepared statement.- Returns:
- Numeric value telling about success of the execution of the statement.
- Throws:
java.sql.SQLException
- Reports database access errors.
-
executeQuery
public java.sql.ResultSet executeQuery() throws java.sql.SQLException
Method to execute prepared statement and return ResultSet.- Returns:
- ResultSet containing data returned from database.
- Throws:
java.sql.SQLException
- Reports database access errors.
-
close
public void close() throws java.sql.SQLException
Method to close the prepared statement.- Throws:
java.sql.SQLException
- Reports database access errors.
-
toString
public java.lang.String toString()
Method to get string representation of the existing query string.- Overrides:
toString
in classjava.lang.Object
- Returns:
- String representation of the existing query string.
-
-