Class ParamInfo

java.lang.Object
net.sourceforge.jtds.jdbc.ParamInfo
All Implemented Interfaces:
Cloneable

class ParamInfo extends Object implements Cloneable
This class is a descriptor for procedure and prepared statement parameters.
Version:
$Id: ParamInfo.java,v 1.16 2005-04-25 11:47:01 alin_sinpalean Exp $
Author:
Mike Hutchinson
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) CharsetInfo
    Character set descriptor (if different from default)
    (package private) byte[]
    TDS 8 Collation string.
    (package private) static final int
    Flag as an input parameter.
    (package private) boolean
    Parameter is an output parameter
    (package private) boolean
    Parameter is used as SP return value
    (package private) boolean
    IN parameter has been set
    (package private) boolean
    OUT parameter value is set.
    (package private) boolean
    Parameter should be sent as unicode
    (package private) int
    JDBC type constant from java.sql.Types
    (package private) int
    Length of InputStream
    (package private) int
    Parameter offset in target SQL statement
    (package private) String
    Formal parameter name eg @P1
    (package private) static final int
    Flag as an output parameter.
    (package private) Object
    OUT Parameter value.
    (package private) int
    Parameter decimal precision
    (package private) static final int
    Flag as an return value parameter.
    (package private) int
    Parameter decimal scale
    (package private) String
    SQL type name eg varchar(10)
    (package private) int
    Internal TDS data type
    (package private) static final int
    Flag as a unicode parameter.
    (package private) Object
    Current parameter value
  • Constructor Summary

    Constructors
    Constructor
    Description
    ParamInfo(int pos, boolean isUnicode)
    Construct a parameter with parameter marker offset.
    ParamInfo(int jdbcType, Object value, int flags)
    Construct an initialised parameter with extra attributes.
    ParamInfo(String name, int pos, boolean isRetVal, boolean isUnicode)
    Construct a parameter for statement caching.
    ParamInfo(ColInfo ci, String name, Object value, int length)
    Construct a parameter based on a result set column.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) void
    Clear the IN parameter value and status.
    (package private) void
    Clear the OUT parameter value and status.
    Creates a shallow copy of this ParamInfo instance.
    (package private) byte[]
    getBytes(String charset)
    Get the byte array value of the parameter.
    (package private) Object
    Get the output parameter value.
    (package private) String
    getString(String charset)
    Get the string value of the parameter.
    private static String
    loadFromReader(Reader in, int length)
    Create a String from a Reader stream.
    private static byte[]
    loadFromStream(InputStream in, int length)
    Load a byte array from an InputStream
    (package private) void
    Set the OUT parameter value.

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • INPUT

      static final int INPUT
      Flag as an input parameter.
      See Also:
    • OUTPUT

      static final int OUTPUT
      Flag as an output parameter.
      See Also:
    • RETVAL

      static final int RETVAL
      Flag as an return value parameter.
      See Also:
    • UNICODE

      static final int UNICODE
      Flag as a unicode parameter.
      See Also:
    • tdsType

      int tdsType
      Internal TDS data type
    • jdbcType

      int jdbcType
      JDBC type constant from java.sql.Types
    • name

      String name
      Formal parameter name eg @P1
    • sqlType

      String sqlType
      SQL type name eg varchar(10)
    • markerPos

      int markerPos
      Parameter offset in target SQL statement
    • value

      Object value
      Current parameter value
    • precision

      int precision
      Parameter decimal precision
    • scale

      int scale
      Parameter decimal scale
    • length

      int length
      Length of InputStream
    • isOutput

      boolean isOutput
      Parameter is an output parameter
    • isRetVal

      boolean isRetVal
      Parameter is used as SP return value
    • isSet

      boolean isSet
      IN parameter has been set
    • isUnicode

      boolean isUnicode
      Parameter should be sent as unicode
    • collation

      byte[] collation
      TDS 8 Collation string.
    • charsetInfo

      CharsetInfo charsetInfo
      Character set descriptor (if different from default)
    • isSetOut

      boolean isSetOut
      OUT parameter value is set.
    • outValue

      Object outValue
      OUT Parameter value.
  • Constructor Details

    • ParamInfo

      ParamInfo(int pos, boolean isUnicode)
      Construct a parameter with parameter marker offset.
      Parameters:
      pos - the offset of the ? symbol in the target SQL string
      isUnicode - true if the parameter is Unicode encoded
    • ParamInfo

      ParamInfo(String name, int pos, boolean isRetVal, boolean isUnicode)
      Construct a parameter for statement caching.
      Parameters:
      name - the formal name of the parameter
      pos - the offset of the ? symbol in the parsed SQL string
      isRetVal - true if the parameter is a return value
      isUnicode - true if the parameter is Unicode encoded
    • ParamInfo

      ParamInfo(int jdbcType, Object value, int flags)
      Construct an initialised parameter with extra attributes.
      Parameters:
      jdbcType - the java.sql.Type constant describing this type
      value - the initial parameter value
      flags - the additional attributes eg OUTPUT, RETVAL, UNICODE etc.
    • ParamInfo

      ParamInfo(ColInfo ci, String name, Object value, int length)
      Construct a parameter based on a result set column.
      Parameters:
      ci - the column descriptor
      name - the name for this parameter or null
      value - the column data value
      length - the column data length
  • Method Details

    • getOutValue

      Object getOutValue() throws SQLException
      Get the output parameter value.
      Returns:
      the OUT value as an Object
      Throws:
      SQLException - if the parameter has not been set
    • setOutValue

      void setOutValue(Object value)
      Set the OUT parameter value.
      Parameters:
      value - The data value.
    • clearOutValue

      void clearOutValue()
      Clear the OUT parameter value and status.
    • clearInValue

      void clearInValue()
      Clear the IN parameter value and status.
    • getString

      String getString(String charset) throws IOException
      Get the string value of the parameter.
      Returns:
      The data value as a String or null.
      Throws:
      IOException
    • getBytes

      byte[] getBytes(String charset) throws IOException
      Get the byte array value of the parameter.
      Returns:
      The data value as a byte[] or null.
      Throws:
      IOException
    • loadFromStream

      private static byte[] loadFromStream(InputStream in, int length) throws IOException
      Load a byte array from an InputStream
      Parameters:
      in - The InputStream to read from.
      length - The length of the stream.
      Returns:
      The data as a byte[].
      Throws:
      IOException
    • loadFromReader

      private static String loadFromReader(Reader in, int length) throws IOException
      Create a String from a Reader stream.
      Parameters:
      in - The Reader object with the data.
      length - Number of characters to read.
      Returns:
      The data as a String.
      Throws:
      IOException
    • clone

      public Object clone()
      Creates a shallow copy of this ParamInfo instance. Used by the PreparedStatement batching implementation to duplicate parameters.
      Overrides:
      clone in class Object