org.javasimon.jdbc
Class SimonPreparedStatement

java.lang.Object
  extended by org.javasimon.jdbc.SimonStatement
      extended by org.javasimon.jdbc.SimonPreparedStatement
All Implemented Interfaces:
PreparedStatement, Statement, Wrapper
Direct Known Subclasses:
SimonCallableStatement

public class SimonPreparedStatement
extends SimonStatement
implements PreparedStatement

Simon JDBC proxy prepared statement implementation class.

Since:
1.0
Version:
$Revision: 304 $ $Date: 2011-04-08 10:39:02 +0200 (Fri, 08 Apr 2011) $
Author:
Radovan Sninsky
See Also:
PreparedStatement

Field Summary
protected  String sql
          SQL string.
private  PreparedStatement stmt
           
 
Fields inherited from class org.javasimon.jdbc.SimonStatement
batchSql, conn, prefix, split, sqlCmdLabel, sqlNormalizer
 
Fields inherited from interface java.sql.Statement
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO
 
Constructor Summary
SimonPreparedStatement(Connection conn, PreparedStatement stmt, String sql, String prefix)
          Class constructor, initializes Simons (lifespan, active) related to statement.
 
Method Summary
 void addBatch()
          Adds prepared SQL command into batch list of sql and also into real batch.
 void clearParameters()
          
 boolean execute()
          Measure and execute prepared SQL operation.
 ResultSet executeQuery()
          Measure and execute prepared SQL operation.
 int executeUpdate()
          Measure and execute prepared SQL operation.
 ResultSetMetaData getMetaData()
          
 ParameterMetaData getParameterMetaData()
          
protected  Split prepare()
          Called before each prepared SQL command execution.
 void setArray(int i, Array array)
          
 void setAsciiStream(int i, InputStream inputStream, int i1)
          
 void setBigDecimal(int i, BigDecimal bigDecimal)
          
 void setBinaryStream(int i, InputStream inputStream, int i1)
          
 void setBlob(int i, Blob blob)
          
 void setBoolean(int i, boolean b)
          
 void setByte(int i, byte b)
          
 void setBytes(int i, byte[] bytes)
          
 void setCharacterStream(int i, Reader reader, int i1)
          
 void setClob(int i, Clob clob)
          
 void setDate(int i, Date date)
          
 void setDate(int i, Date date, Calendar calendar)
          
 void setDouble(int i, double v)
          
 void setFloat(int i, float v)
          
 void setInt(int i, int i1)
          
 void setLong(int i, long l)
          
 void setNull(int i, int i1)
          
 void setNull(int i, int i1, String s)
          
 void setObject(int i, Object o)
          
 void setObject(int i, Object o, int i1)
          
 void setObject(int i, Object o, int i1, int i2)
          
 void setRef(int i, Ref ref)
          
 void setShort(int i, short i1)
          
 void setString(int i, String s)
          
 void setTime(int i, Time time)
          
 void setTime(int i, Time time, Calendar calendar)
          
 void setTimestamp(int i, Timestamp timestamp)
          
 void setTimestamp(int i, Timestamp timestamp, Calendar calendar)
          
 void setUnicodeStream(int i, InputStream inputStream, int i1)
          
 void setURL(int i, URL url)
          
 
Methods inherited from class org.javasimon.jdbc.SimonStatement
addBatch, cancel, clearBatch, clearWarnings, close, execute, execute, execute, execute, executeBatch, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, finish, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, prepare, prepare, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setQueryTimeout, startSplit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.sql.PreparedStatement
setAsciiStream, setAsciiStream, setBinaryStream, setBinaryStream, setBlob, setBlob, setCharacterStream, setCharacterStream, setClob, setClob, setNCharacterStream, setNCharacterStream, setNClob, setNClob, setNClob, setNString, setRowId, setSQLXML
 
Methods inherited from interface java.sql.Statement
addBatch, cancel, clearBatch, clearWarnings, close, execute, execute, execute, execute, executeBatch, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isPoolable, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout
 
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
 

Field Detail

sql

protected String sql
SQL string.


stmt

private PreparedStatement stmt
Constructor Detail

SimonPreparedStatement

SimonPreparedStatement(Connection conn,
                       PreparedStatement stmt,
                       String sql,
                       String prefix)
Class constructor, initializes Simons (lifespan, active) related to statement.

Parameters:
conn - database connection (Simon impl.)
stmt - real prepared statement
sql - sql command
prefix - hierarchy prefix for statement Simons
Method Detail

prepare

protected final Split prepare()
Called before each prepared SQL command execution. Prepares (obtains and starts) Stopwatch Simon for measure SQL operation.

Returns:
simon stopwatch object or null if sql is null or empty

executeQuery

public final ResultSet executeQuery()
                             throws SQLException
Measure and execute prepared SQL operation.

Specified by:
executeQuery in interface PreparedStatement
Returns:
database rows and columns
Throws:
SQLException - if real calls fails

executeUpdate

public final int executeUpdate()
                        throws SQLException
Measure and execute prepared SQL operation.

Specified by:
executeUpdate in interface PreparedStatement
Returns:
count of updated rows
Throws:
SQLException - if real calls fails

execute

public final boolean execute()
                      throws SQLException
Measure and execute prepared SQL operation.

Specified by:
execute in interface PreparedStatement
Returns:
true if the first result is a ResultSet object; false if it is an update count or there are no results
Throws:
SQLException - if real calls fails

addBatch

public final void addBatch()
                    throws SQLException
Adds prepared SQL command into batch list of sql and also into real batch.

Specified by:
addBatch in interface PreparedStatement
Throws:
SQLException - if real calls fails

setNull

public final void setNull(int i,
                          int i1)
                   throws SQLException

Specified by:
setNull in interface PreparedStatement
Throws:
SQLException

setBoolean

public final void setBoolean(int i,
                             boolean b)
                      throws SQLException

Specified by:
setBoolean in interface PreparedStatement
Throws:
SQLException

setByte

public final void setByte(int i,
                          byte b)
                   throws SQLException

Specified by:
setByte in interface PreparedStatement
Throws:
SQLException

setShort

public final void setShort(int i,
                           short i1)
                    throws SQLException

Specified by:
setShort in interface PreparedStatement
Throws:
SQLException

setInt

public final void setInt(int i,
                         int i1)
                  throws SQLException

Specified by:
setInt in interface PreparedStatement
Throws:
SQLException

setLong

public final void setLong(int i,
                          long l)
                   throws SQLException

Specified by:
setLong in interface PreparedStatement
Throws:
SQLException

setFloat

public final void setFloat(int i,
                           float v)
                    throws SQLException

Specified by:
setFloat in interface PreparedStatement
Throws:
SQLException

setDouble

public final void setDouble(int i,
                            double v)
                     throws SQLException

Specified by:
setDouble in interface PreparedStatement
Throws:
SQLException

setBigDecimal

public final void setBigDecimal(int i,
                                BigDecimal bigDecimal)
                         throws SQLException

Specified by:
setBigDecimal in interface PreparedStatement
Throws:
SQLException

setString

public final void setString(int i,
                            String s)
                     throws SQLException

Specified by:
setString in interface PreparedStatement
Throws:
SQLException

setBytes

public final void setBytes(int i,
                           byte[] bytes)
                    throws SQLException

Specified by:
setBytes in interface PreparedStatement
Throws:
SQLException

setDate

public final void setDate(int i,
                          Date date)
                   throws SQLException

Specified by:
setDate in interface PreparedStatement
Throws:
SQLException

setTime

public final void setTime(int i,
                          Time time)
                   throws SQLException

Specified by:
setTime in interface PreparedStatement
Throws:
SQLException

setTimestamp

public final void setTimestamp(int i,
                               Timestamp timestamp)
                        throws SQLException

Specified by:
setTimestamp in interface PreparedStatement
Throws:
SQLException

setAsciiStream

public final void setAsciiStream(int i,
                                 InputStream inputStream,
                                 int i1)
                          throws SQLException

Specified by:
setAsciiStream in interface PreparedStatement
Throws:
SQLException

setUnicodeStream

public final void setUnicodeStream(int i,
                                   InputStream inputStream,
                                   int i1)
                            throws SQLException

Specified by:
setUnicodeStream in interface PreparedStatement
Throws:
SQLException

setBinaryStream

public final void setBinaryStream(int i,
                                  InputStream inputStream,
                                  int i1)
                           throws SQLException

Specified by:
setBinaryStream in interface PreparedStatement
Throws:
SQLException

clearParameters

public final void clearParameters()
                           throws SQLException

Specified by:
clearParameters in interface PreparedStatement
Throws:
SQLException

setObject

public final void setObject(int i,
                            Object o,
                            int i1)
                     throws SQLException

Specified by:
setObject in interface PreparedStatement
Throws:
SQLException

setObject

public final void setObject(int i,
                            Object o)
                     throws SQLException

Specified by:
setObject in interface PreparedStatement
Throws:
SQLException

setObject

public final void setObject(int i,
                            Object o,
                            int i1,
                            int i2)
                     throws SQLException

Specified by:
setObject in interface PreparedStatement
Throws:
SQLException

setCharacterStream

public final void setCharacterStream(int i,
                                     Reader reader,
                                     int i1)
                              throws SQLException

Specified by:
setCharacterStream in interface PreparedStatement
Throws:
SQLException

setRef

public final void setRef(int i,
                         Ref ref)
                  throws SQLException

Specified by:
setRef in interface PreparedStatement
Throws:
SQLException

setBlob

public final void setBlob(int i,
                          Blob blob)
                   throws SQLException

Specified by:
setBlob in interface PreparedStatement
Throws:
SQLException

setClob

public final void setClob(int i,
                          Clob clob)
                   throws SQLException

Specified by:
setClob in interface PreparedStatement
Throws:
SQLException

setArray

public final void setArray(int i,
                           Array array)
                    throws SQLException

Specified by:
setArray in interface PreparedStatement
Throws:
SQLException

getMetaData

public final ResultSetMetaData getMetaData()
                                    throws SQLException

Specified by:
getMetaData in interface PreparedStatement
Throws:
SQLException

setDate

public final void setDate(int i,
                          Date date,
                          Calendar calendar)
                   throws SQLException

Specified by:
setDate in interface PreparedStatement
Throws:
SQLException

setTime

public final void setTime(int i,
                          Time time,
                          Calendar calendar)
                   throws SQLException

Specified by:
setTime in interface PreparedStatement
Throws:
SQLException

setTimestamp

public final void setTimestamp(int i,
                               Timestamp timestamp,
                               Calendar calendar)
                        throws SQLException

Specified by:
setTimestamp in interface PreparedStatement
Throws:
SQLException

setNull

public final void setNull(int i,
                          int i1,
                          String s)
                   throws SQLException

Specified by:
setNull in interface PreparedStatement
Throws:
SQLException

setURL

public final void setURL(int i,
                         URL url)
                  throws SQLException

Specified by:
setURL in interface PreparedStatement
Throws:
SQLException

getParameterMetaData

public final ParameterMetaData getParameterMetaData()
                                             throws SQLException

Specified by:
getParameterMetaData in interface PreparedStatement
Throws:
SQLException


Copyright © 2011. All Rights Reserved.