org.skife.jdbi.v2
Class SQLStatement<SelfType extends SQLStatement<SelfType>>

java.lang.Object
  extended by org.skife.jdbi.v2.SQLStatement<SelfType>
Direct Known Subclasses:
Call, PreparedBatchPart, Query, Update

public abstract class SQLStatement<SelfType extends SQLStatement<SelfType>>
extends Object

This class provides the common functions between Query and Update. It defines most of the argument binding functions used by its subclasses.


Method Summary
 SelfType addStatementCustomizer(StatementCustomizer customizer)
          Provides a means for custom statement modification.
 SelfType bind(int position, Argument argument)
          Used if you need to have some exotic parameter bound.
 SelfType bind(int position, BigDecimal value)
          Bind an argument positionally
 SelfType bind(int position, Blob value)
          Bind an argument positionally
 SelfType bind(int position, boolean value)
          Bind an argument positionally
 SelfType bind(int position, Boolean value)
          Bind an argument positionally
 SelfType bind(int position, byte value)
          Bind an argument positionally
 SelfType bind(int position, Byte value)
          Bind an argument positionally
 SelfType bind(int position, byte[] value)
          Bind an argument positionally
 SelfType bind(int position, char value)
          Bind an argument positionally
 SelfType bind(int position, Character value)
          Bind an argument positionally
 SelfType bind(int position, Clob value)
          Bind an argument positionally
 SelfType bind(int position, Date value)
          Bind an argument positionally
 SelfType bind(int position, Date value)
          Bind an argument positionally
 SelfType bind(int position, double value)
          Bind an argument positionally
 SelfType bind(int position, Double value)
          Bind an argument positionally
 SelfType bind(int position, float value)
          Bind an argument positionally
 SelfType bind(int position, Float value)
          Bind an argument positionally
 SelfType bind(int position, int value)
          Bind an argument positionally
 SelfType bind(int position, Integer value)
          Bind an argument positionally
 SelfType bind(int position, long value)
          Bind an argument positionally
 SelfType bind(int position, Long value)
          Bind an argument positionally
 SelfType bind(int position, Object value)
          Bind an argument positionally
 SelfType bind(int position, Reader value, int length)
          Bind an argument positionally
 SelfType bind(int position, short value)
          Bind an argument positionally
 SelfType bind(int position, Short value)
          Bind an argument positionally
 SelfType bind(int position, String value)
          Bind an argument positionally
 SelfType bind(int position, Time value)
          Bind an argument positionally
 SelfType bind(int position, Timestamp value)
          Bind an argument positionally
 SelfType bind(int position, URL value)
          Bind an argument positionally
 SelfType bind(String name, Argument argument)
          Used if you need to have some exotic parameter bound.
 SelfType bind(String name, BigDecimal value)
          Bind an argument by name
 SelfType bind(String name, Blob value)
          Bind an argument by name
 SelfType bind(String name, boolean value)
          Bind an argument by name
 SelfType bind(String name, Boolean value)
          Bind an argument by name
 SelfType bind(String name, byte value)
          Bind an argument by name
 SelfType bind(String name, Byte value)
          Bind an argument by name
 SelfType bind(String name, byte[] value)
          Bind an argument by name
 SelfType bind(String name, char value)
          Bind an argument by name
 SelfType bind(String name, Character value)
          Bind an argument by name
 SelfType bind(String name, Clob value)
          Bind an argument by name
 SelfType bind(String name, Date value)
          Bind an argument by name
 SelfType bind(String name, Date value)
          Bind an argument by name
 SelfType bind(String name, double value)
          Bind an argument by name
 SelfType bind(String name, Double value)
          Bind an argument by name
 SelfType bind(String name, float value)
          Bind an argument by name
 SelfType bind(String name, Float value)
          Bind an argument by name
 SelfType bind(String name, int value)
          Bind an argument by name
 SelfType bind(String name, Integer value)
          Bind an argument by name
 SelfType bind(String name, long value)
          Bind an argument by name
 SelfType bind(String name, Long value)
          Bind an argument by name
 SelfType bind(String name, Object value)
          Bind an argument by name
 SelfType bind(String name, Reader value, int length)
          Bind an argument by name
 SelfType bind(String name, short value)
          Bind an argument by name
 SelfType bind(String name, Short value)
          Bind an argument by name
 SelfType bind(String name, String value)
          Bind an argument by name
 SelfType bind(String name, Time value)
          Bind an argument by name
 SelfType bind(String name, Timestamp value)
          Bind an argument by name
 SelfType bind(String name, URL value)
          Bind an argument by name
 SelfType bindASCIIStream(int position, InputStream value, int length)
          Bind an argument positionally
 SelfType bindASCIIStream(String name, InputStream value, int length)
          Bind an argument by name
 SelfType bindAsInt(int position, boolean value)
          Bind an argument positionally
 SelfType bindAsInt(int position, Boolean value)
          Bind an argument positionally
 SelfType bindAsInt(String name, boolean value)
          Bind an argument by name
 SelfType bindAsInt(String name, Boolean value)
          Bind an argument by name
 SelfType bindBinaryStream(int position, InputStream value, int length)
          Bind an argument positionally
 SelfType bindBinaryStream(String name, InputStream value, int length)
          Bind an argument by name
 SelfType bindBySqlType(int position, Object value, int sqlType)
          Bind a value using a specific type from java.sql.Types via PreparedStatement#setObject(int, Object, int)
 SelfType bindBySqlType(String name, Object value, int sqlType)
          Bind a value using a specific type from java.sql.Types via PreparedStatement#setObject(int, Object, int)
 SelfType bindFromMap(Map<String,? extends Object> args)
          Binds named parameters from a map of String to Object instances
 SelfType bindFromProperties(Object o)
          Binds named parameters from JavaBean properties on o.
 SelfType bindNamedArgumentFinder(NamedArgumentFinder namedArgumentFinder)
          Binds a new NamedArgumentFinder.
 SelfType bindNull(int position, int sqlType)
          Bind NULL to be set for a given argument.
 SelfType bindNull(String name, int sqlType)
          Bind NULL to be set for a given argument.
 SelfType define(Map<String,? extends Object> values)
          Adds all key/value pairs in the Map to the StatementContext.
 SelfType define(String key, Object value)
          Define a value on the StatementContext.
protected  ConcreteStatementContext getConcreteContext()
           
protected  Connection getConnection()
           
 StatementContext getContext()
          Obtain the statement context associated with this statement
protected  SQLLog getLog()
           
protected  Binding getParameters()
           
protected  Binding getParams()
           
protected  StatementRewriter getRewriter()
           
protected  String getSql()
          The un-translated SQL used to create this statement
protected  StatementBuilder getStatementBuilder()
           
protected  Collection<StatementCustomizer> getStatementCustomizers()
           
protected  StatementLocator getStatementLocator()
           
protected  TimingCollector getTimingCollector()
           
protected
<Result> Result
internalExecute(org.skife.jdbi.v2.QueryPreperator prep, org.skife.jdbi.v2.QueryResultMunger<Result> munger, org.skife.jdbi.v2.QueryPostMungeCleanup cleanup)
           
 void setFetchDirection(int value)
           
 SelfType setQueryTimeout(int seconds)
          Set the query timeout, in seconds, on the prepared statement
 void setStatementLocator(StatementLocator locator)
          Override the statement locator used for this statement
 void setStatementRewriter(StatementRewriter rewriter)
          Override the statement rewriter used for this statement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addStatementCustomizer

public SelfType addStatementCustomizer(StatementCustomizer customizer)
Provides a means for custom statement modification. Common cusotmizations have their own methods, such as Query.setMaxRows(int)

Parameters:
customizer - instance to be used to cstomize a statement
Returns:
modified statement

bind

public SelfType bind(int position,
                     Argument argument)
Used if you need to have some exotic parameter bound.

Parameters:
position - position to bindBinaryStream this argument, starting at 0
argument - exotic argument factory
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           BigDecimal value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           Blob value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           boolean value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           Boolean value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           byte value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           Byte value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           byte[] value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           char value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           Character value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           Clob value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           Date value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           Date value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           double value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           Double value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           float value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           Float value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           int value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           Integer value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           long value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           Long value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           Object value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           Reader value,
                           int length)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
length - number of characters to read
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           short value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           Short value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           String value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           Time value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           Timestamp value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(int position,
                           URL value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bind

public SelfType bind(String name,
                     Argument argument)
Used if you need to have some exotic parameter bound.

Parameters:
name - name to bindBinaryStream this argument
argument - exotic argument factory
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           BigDecimal value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           Blob value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           boolean value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           Boolean value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           byte value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           Byte value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           byte[] value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           char value)
Bind an argument by name

Parameters:
name - name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           Character value)
Bind an argument by name

Parameters:
name - token name to bind the parameter to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           Clob value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           Date value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           Date value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           double value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           Double value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           float value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           Float value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           int value)
Bind an argument by name

Parameters:
name - name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           Integer value)
Bind an argument by name

Parameters:
name - name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           long value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           Long value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           Object value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           Reader value,
                           int length)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
length - number of characters to read
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           short value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           Short value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           String value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           Time value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           Timestamp value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bind

public final SelfType bind(String name,
                           URL value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bindASCIIStream

public final SelfType bindASCIIStream(int position,
                                      InputStream value,
                                      int length)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
length - how long is the stream being bound?
Returns:
the same Query instance

bindASCIIStream

public final SelfType bindASCIIStream(String name,
                                      InputStream value,
                                      int length)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
length - bytes to read from value
Returns:
the same Query instance

bindAsInt

public final SelfType bindAsInt(int position,
                                boolean value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bindAsInt

public final SelfType bindAsInt(int position,
                                Boolean value)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bindAsInt

public final SelfType bindAsInt(String name,
                                boolean value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bindAsInt

public final SelfType bindAsInt(String name,
                                Boolean value)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
Returns:
the same Query instance

bindBinaryStream

public final SelfType bindBinaryStream(int position,
                                       InputStream value,
                                       int length)
Bind an argument positionally

Parameters:
position - position to bind the paramater at, starting at 0
value - to bind
Returns:
the same Query instance

bindBinaryStream

public final SelfType bindBinaryStream(String name,
                                       InputStream value,
                                       int length)
Bind an argument by name

Parameters:
name - token name to bind the paramater to
value - to bind
length - bytes to read from value
Returns:
the same Query instance

bindBySqlType

public final SelfType bindBySqlType(int position,
                                    Object value,
                                    int sqlType)
Bind a value using a specific type from java.sql.Types via PreparedStatement#setObject(int, Object, int)

Parameters:
position - position to bind NULL to, starting at 0
value - Value to bind
sqlType - The sqlType from java.sql.Types
Returns:
self

bindBySqlType

public final SelfType bindBySqlType(String name,
                                    Object value,
                                    int sqlType)
Bind a value using a specific type from java.sql.Types via PreparedStatement#setObject(int, Object, int)

Parameters:
name - Named parameter to bind at
value - Value to bind
sqlType - The sqlType from java.sql.Types
Returns:
self

bindFromMap

public SelfType bindFromMap(Map<String,? extends Object> args)
Binds named parameters from a map of String to Object instances

Parameters:
args - map where keys are matched to named parameters in order to bind arguments. Can be null, in this case, the binding has no effect.
Returns:
modified statement

bindFromProperties

public SelfType bindFromProperties(Object o)
Binds named parameters from JavaBean properties on o.

Parameters:
o - source of named parameter values to use as arguments
Returns:
modified statement

bindNamedArgumentFinder

public SelfType bindNamedArgumentFinder(NamedArgumentFinder namedArgumentFinder)
Binds a new NamedArgumentFinder.

Parameters:
namedArgumentFinder - A NamedArgumentFinder to bind. Can be null.

bindNull

public final SelfType bindNull(int position,
                               int sqlType)
Bind NULL to be set for a given argument.

Parameters:
position - position to bind NULL to, starting at 0
sqlType - The sqlType must be set and is a value from java.sql.Types
Returns:
the same statement instance

bindNull

public final SelfType bindNull(String name,
                               int sqlType)
Bind NULL to be set for a given argument.

Parameters:
name - Named parameter to bind to
sqlType - The sqlType must be set and is a value from java.sql.Types
Returns:
the same statement instance

define

public SelfType define(Map<String,? extends Object> values)
Adds all key/value pairs in the Map to the StatementContext.

Parameters:
values - containing key/value pairs.
Returns:
this

define

public SelfType define(String key,
                       Object value)
Define a value on the StatementContext.

Parameters:
key - Key to access this value from the StatementContext
value - Value to setAttribute on the StatementContext
Returns:
this

getConcreteContext

protected ConcreteStatementContext getConcreteContext()

getConnection

protected Connection getConnection()

getContext

public StatementContext getContext()
Obtain the statement context associated with this statement


getLog

protected SQLLog getLog()

getParameters

protected Binding getParameters()

getParams

protected Binding getParams()

getRewriter

protected StatementRewriter getRewriter()

getSql

protected String getSql()
The un-translated SQL used to create this statement


getStatementBuilder

protected StatementBuilder getStatementBuilder()

getStatementCustomizers

protected Collection<StatementCustomizer> getStatementCustomizers()

getStatementLocator

protected StatementLocator getStatementLocator()

getTimingCollector

protected TimingCollector getTimingCollector()

internalExecute

protected <Result> Result internalExecute(org.skife.jdbi.v2.QueryPreperator prep,
                                          org.skife.jdbi.v2.QueryResultMunger<Result> munger,
                                          org.skife.jdbi.v2.QueryPostMungeCleanup cleanup)

setFetchDirection

public void setFetchDirection(int value)

setQueryTimeout

public SelfType setQueryTimeout(int seconds)
Set the query timeout, in seconds, on the prepared statement

Parameters:
seconds - number of seconds before timing out
Returns:
the same instance

setStatementLocator

public void setStatementLocator(StatementLocator locator)
Override the statement locator used for this statement


setStatementRewriter

public void setStatementRewriter(StatementRewriter rewriter)
Override the statement rewriter used for this statement



Copyright © 2011. All Rights Reserved.