Package net.sourceforge.jtds.jdbc
Class ParamInfo
java.lang.Object
net.sourceforge.jtds.jdbc.ParamInfo
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescription(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
ConstructorsConstructorDescriptionParamInfo
(int pos, boolean isUnicode) Construct a parameter with parameter marker offset.Construct an initialised parameter with extra attributes.Construct a parameter for statement caching.Construct a parameter based on a result set column. -
Method Summary
Modifier and TypeMethodDescription(package private) void
Clear the IN parameter value and status.(package private) void
Clear the OUT parameter value and status.clone()
Creates a shallow copy of thisParamInfo
instance.(package private) byte[]
Get the byte array value of the parameter.(package private) Object
Get the output parameter value.(package private) String
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
static final int INPUTFlag as an input parameter.- See Also:
-
OUTPUT
static final int OUTPUTFlag as an output parameter.- See Also:
-
RETVAL
static final int RETVALFlag as an return value parameter.- See Also:
-
UNICODE
static final int UNICODEFlag as a unicode parameter.- See Also:
-
tdsType
int tdsTypeInternal TDS data type -
jdbcType
int jdbcTypeJDBC type constant from java.sql.Types -
name
String nameFormal parameter name eg @P1 -
sqlType
String sqlTypeSQL type name eg varchar(10) -
markerPos
int markerPosParameter offset in target SQL statement -
value
Object valueCurrent parameter value -
precision
int precisionParameter decimal precision -
scale
int scaleParameter decimal scale -
length
int lengthLength of InputStream -
isOutput
boolean isOutputParameter is an output parameter -
isRetVal
boolean isRetValParameter is used as SP return value -
isSet
boolean isSetIN parameter has been set -
isUnicode
boolean isUnicodeParameter should be sent as unicode -
collation
byte[] collationTDS 8 Collation string. -
charsetInfo
CharsetInfo charsetInfoCharacter set descriptor (if different from default) -
isSetOut
boolean isSetOutOUT parameter value is set. -
outValue
Object outValueOUT 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 stringisUnicode
-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 parameterpos
- the offset of the ? symbol in the parsed SQL stringisRetVal
-true
if the parameter is a return valueisUnicode
-true
if the parameter is Unicode encoded
-
ParamInfo
ParamInfo(int jdbcType, Object value, int flags) Construct an initialised parameter with extra attributes.- Parameters:
jdbcType
- thejava.sql.Type
constant describing this typevalue
- the initial parameter valueflags
- the additional attributes eg OUTPUT, RETVAL, UNICODE etc.
-
ParamInfo
Construct a parameter based on a result set column.- Parameters:
ci
- the column descriptorname
- the name for this parameter or nullvalue
- the column data valuelength
- the column data length
-
-
Method Details
-
getOutValue
Get the output parameter value.- Returns:
- the OUT value as an
Object
- Throws:
SQLException
- if the parameter has not been set
-
setOutValue
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
Get the string value of the parameter.- Returns:
- The data value as a
String
or null. - Throws:
IOException
-
getBytes
Get the byte array value of the parameter.- Returns:
- The data value as a
byte[]
or null. - Throws:
IOException
-
loadFromStream
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
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
Creates a shallow copy of thisParamInfo
instance. Used by thePreparedStatement
batching implementation to duplicate parameters.
-