org.postgresql.core
Interface ParameterList


public interface ParameterList

Abstraction of a list of parameters to be substituted into a Query. The protocol-specific details of how to efficiently store and stream the parameters is hidden behind implementations of this interface.

In general, instances of ParameterList are associated with a particular Query object (the one that created them) and shouldn't be used against another Query.

Parameter indexes are 1-based to match JDBC's PreparedStatement, i.e. the first parameter has index 1.

Author:
Oliver Jowett (oliver@opencloud.com)

Method Summary
 void clear()
          Unbind all parameter values bound in this list.
 ParameterList copy()
          Perform a shallow copy of this ParameterList, returning a new instance (still suitable for passing to the owning Query).
 int getInParameterCount()
          Get the number of IN parameters in this list.
 int getOutParameterCount()
          Get the number of OUT parameters in this list.
 int getParameterCount()
          Get the number of parameters in this list.
 int[] getTypeOIDs()
          Return the oids of the parameters in this list.
 void registerOutParameter(int index, int sqlType)
           
 void setBytea(int index, byte[] data, int offset, int length)
          Binds a binary bytea value stored as a bytearray to a parameter.
 void setBytea(int index, InputStream stream, int length)
          Binds a binary bytea value stored as an InputStream.
 void setIntParameter(int index, int value)
          Binds an integer value to a parameter.
 void setLiteralParameter(int index, String value, int oid)
          Binds a String value that is an unquoted literal to the server's query parser (for example, a bare integer) to a parameter.
 void setNull(int index, int oid)
          Binds a SQL NULL value to a parameter.
 void setStringParameter(int index, String value, int oid)
          Binds a String value that needs to be quoted for the server's parser to understand (for example, a timestamp) to a parameter.
 String toString(int index)
          Return a human-readable representation of a particular parameter in this ParameterList.
 

Method Detail

registerOutParameter

void registerOutParameter(int index,
                          int sqlType)
                          throws SQLException
Throws:
SQLException

getParameterCount

int getParameterCount()
Get the number of parameters in this list. This value never changes for a particular instance, and might be zero.

Returns:
the number of parameters in this list.

getInParameterCount

int getInParameterCount()
Get the number of IN parameters in this list.

Returns:
the number of IN parameters in this list

getOutParameterCount

int getOutParameterCount()
Get the number of OUT parameters in this list.

Returns:
the number of OUT parameters in this list

getTypeOIDs

int[] getTypeOIDs()
Return the oids of the parameters in this list. May be null for a ParameterList that does not support typing of parameters.


setIntParameter

void setIntParameter(int index,
                     int value)
                     throws SQLException
Binds an integer value to a parameter. The type of the parameter is implicitly 'int4'.

Parameters:
index - the 1-based parameter index to bind.
value - the integer value to use.
Throws:
SQLException - on error or if index is out of range

setLiteralParameter

void setLiteralParameter(int index,
                         String value,
                         int oid)
                         throws SQLException
Binds a String value that is an unquoted literal to the server's query parser (for example, a bare integer) to a parameter. Associated with the parameter is a typename for the parameter that should correspond to an entry in pg_types.

Parameters:
index - the 1-based parameter index to bind.
value - the unquoted literal string to use.
oid - the type OID of the parameter, or 0 to infer the type.
Throws:
SQLException - on error or if index is out of range

setStringParameter

void setStringParameter(int index,
                        String value,
                        int oid)
                        throws SQLException
Binds a String value that needs to be quoted for the server's parser to understand (for example, a timestamp) to a parameter. Associated with the parameter is a typename for the parameter that should correspond to an entry in pg_types.

Parameters:
index - the 1-based parameter index to bind.
value - the quoted string to use.
oid - the type OID of the parameter, or 0 to infer the type.
Throws:
SQLException - on error or if index is out of range

setBytea

void setBytea(int index,
              byte[] data,
              int offset,
              int length)
              throws SQLException
Binds a binary bytea value stored as a bytearray to a parameter. The parameter's type is implicitly set to 'bytea'. The bytearray's contains should remain unchanged until query execution has completed.

Parameters:
index - the 1-based parameter index to bind.
data - an array containing the raw data value
offset - the offset within data of the start of the parameter data.
length - the number of bytes of parameter data within data to use.
Throws:
SQLException - on error or if index is out of range

setBytea

void setBytea(int index,
              InputStream stream,
              int length)
              throws SQLException
Binds a binary bytea value stored as an InputStream. The parameter's type is implicitly set to 'bytea'. The stream should remain valid until query execution has completed.

Parameters:
index - the 1-based parameter index to bind.
stream - a stream containing the parameter data.
length - the number of bytes of parameter data to read from stream.
Throws:
SQLException - on error or if index is out of range

setNull

void setNull(int index,
             int oid)
             throws SQLException
Binds a SQL NULL value to a parameter. Associated with the parameter is a typename for the parameter that should correspond to an entry in pg_types.

Parameters:
index - the 1-based parameter index to bind.
oid - the type OID of the parameter, or 0 to infer the type.
Throws:
SQLException - on error or if index is out of range

copy

ParameterList copy()
Perform a shallow copy of this ParameterList, returning a new instance (still suitable for passing to the owning Query). If this ParameterList is immutable, copy() may return the same immutable object.

Returns:
a new ParameterList instance

clear

void clear()
Unbind all parameter values bound in this list.


toString

String toString(int index)
Return a human-readable representation of a particular parameter in this ParameterList. If the parameter is not bound, returns "?".

Parameters:
index - the 1-based parameter index to bind.
Returns:
a string representation of the parameter.


Copyright © 2013. All Rights Reserved.