net.sourceforge.jtds.jdbc

Class ParamInfo

Implemented Interfaces:
Cloneable

(package private) class ParamInfo
extends java.lang.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

(package private) static int
INPUT
Flag as an input parameter.
(package private) static int
OUTPUT
Flag as an output parameter.
(package private) static int
RETVAL
Flag as an return value parameter.
(package private) static int
UNICODE
Flag as a unicode parameter.
(package private) CharsetInfo
charsetInfo
Character set descriptor (if different from default)
(package private) byte[]
collation
TDS 8 Collation string.
(package private) boolean
isOutput
Parameter is an output parameter
(package private) boolean
isRetVal
Parameter is used as SP return value
(package private) boolean
isSet
IN parameter has been set
(package private) boolean
isSetOut
OUT parameter value is set.
(package private) boolean
isUnicode
Parameter should be sent as unicode
(package private) int
jdbcType
JDBC type constant from java.sql.Types
(package private) int
length
Length of InputStream
(package private) int
markerPos
Parameter offset in target SQL statement
(package private) String
name
Formal parameter name eg @P1
(package private) Object
outValue
OUT Parameter value.
(package private) int
precision
Parameter decimal precision
(package private) int
scale
Parameter decimal scale
(package private) String
sqlType
SQL type name eg varchar(10)
(package private) int
tdsType
Internal TDS data type
(package private) Object
value
Current parameter value

Constructor Summary

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

Method Summary

(package private) void
clearInValue()
Clear the IN parameter value and status.
(package private) void
clearOutValue()
Clear the OUT parameter value and status.
Object
clone()
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
getOutValue()
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
setOutValue(Object value)
Set the OUT parameter value.

Field Details

INPUT

(package private) static final int INPUT
Flag as an input parameter.
Field Value:
0

OUTPUT

(package private) static final int OUTPUT
Flag as an output parameter.
Field Value:
1

RETVAL

(package private) static final int RETVAL
Flag as an return value parameter.
Field Value:
2

UNICODE

(package private) static final int UNICODE
Flag as a unicode parameter.
Field Value:
4

charsetInfo

(package private)  CharsetInfo charsetInfo
Character set descriptor (if different from default)

collation

(package private)  byte[] collation
TDS 8 Collation string.

isOutput

(package private)  boolean isOutput
Parameter is an output parameter

isRetVal

(package private)  boolean isRetVal
Parameter is used as SP return value

isSet

(package private)  boolean isSet
IN parameter has been set

isSetOut

(package private)  boolean isSetOut
OUT parameter value is set.

isUnicode

(package private)  boolean isUnicode
Parameter should be sent as unicode

jdbcType

(package private)  int jdbcType
JDBC type constant from java.sql.Types

length

(package private)  int length
Length of InputStream

markerPos

(package private)  int markerPos
Parameter offset in target SQL statement

name

(package private)  String name
Formal parameter name eg @P1

outValue

(package private)  Object outValue
OUT Parameter value.

precision

(package private)  int precision
Parameter decimal precision

scale

(package private)  int scale
Parameter decimal scale

sqlType

(package private)  String sqlType
SQL type name eg varchar(10)

tdsType

(package private)  int tdsType
Internal TDS data type

value

(package private)  Object value
Current parameter value

Constructor Details

ParamInfo

(package private)  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

(package private)  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

(package private)  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

(package private)  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

clearInValue

(package private)  void clearInValue()
Clear the IN parameter value and status.

clearOutValue

(package private)  void clearOutValue()
Clear the OUT parameter value and status.

clone

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

getBytes

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

getOutValue

(package private)  Object getOutValue()
            throws SQLException
Get the output parameter value.
Returns:
the OUT value as an Object

getString

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

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.

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[].

setOutValue

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

Generated on June 12 2008