Package net.sourceforge.jtds.jdbc
Class ParamInfo
- java.lang.Object
-
- net.sourceforge.jtds.jdbc.ParamInfo
-
- All Implemented Interfaces:
java.lang.Cloneable
class ParamInfo extends java.lang.Object implements java.lang.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
charsetInfo
Character set descriptor (if different from default)(package private) byte[]
collation
TDS 8 Collation string.(package private) static int
INPUT
Flag as an input parameter.(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) java.lang.String
name
Formal parameter name eg @P1(package private) static int
OUTPUT
Flag as an output parameter.(package private) java.lang.Object
outValue
OUT Parameter value.(package private) int
precision
Parameter decimal precision(package private) static int
RETVAL
Flag as an return value parameter.(package private) int
scale
Parameter decimal scale(package private) java.lang.String
sqlType
SQL type name eg varchar(10)(package private) int
tdsType
Internal TDS data type(package private) static int
UNICODE
Flag as a unicode parameter.(package private) java.lang.Object
value
Current parameter value
-
Constructor Summary
Constructors Constructor Description ParamInfo(int pos, boolean isUnicode)
Construct a parameter with parameter marker offset.ParamInfo(int jdbcType, java.lang.Object value, int flags)
Construct an initialised parameter with extra attributes.ParamInfo(java.lang.String name, int pos, boolean isRetVal, boolean isUnicode)
Construct a parameter for statement caching.ParamInfo(ColInfo ci, java.lang.String name, java.lang.Object value, int length)
Construct a parameter based on a result set column.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
clearInValue()
Clear the IN parameter value and status.(package private) void
clearOutValue()
Clear the OUT parameter value and status.java.lang.Object
clone()
Creates a shallow copy of thisParamInfo
instance.(package private) byte[]
getBytes(java.lang.String charset)
Get the byte array value of the parameter.(package private) java.lang.Object
getOutValue()
Get the output parameter value.(package private) java.lang.String
getString(java.lang.String charset)
Get the string value of the parameter.private static java.lang.String
loadFromReader(java.io.Reader in, int length)
Create a String from a Reader stream.private static byte[]
loadFromStream(java.io.InputStream in, int length)
Load a byte array from an InputStream(package private) void
setOutValue(java.lang.Object value)
Set the OUT parameter value.
-
-
-
Field Detail
-
INPUT
static final int INPUT
Flag as an input parameter.- See Also:
- Constant Field Values
-
OUTPUT
static final int OUTPUT
Flag as an output parameter.- See Also:
- Constant Field Values
-
RETVAL
static final int RETVAL
Flag as an return value parameter.- See Also:
- Constant Field Values
-
UNICODE
static final int UNICODE
Flag as a unicode parameter.- See Also:
- Constant Field Values
-
tdsType
int tdsType
Internal TDS data type
-
jdbcType
int jdbcType
JDBC type constant from java.sql.Types
-
name
java.lang.String name
Formal parameter name eg @P1
-
sqlType
java.lang.String sqlType
SQL type name eg varchar(10)
-
markerPos
int markerPos
Parameter offset in target SQL statement
-
value
java.lang.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
java.lang.Object outValue
OUT Parameter value.
-
-
Constructor Detail
-
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(java.lang.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, java.lang.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
ParamInfo(ColInfo ci, java.lang.String name, java.lang.Object value, int length)
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 Detail
-
getOutValue
java.lang.Object getOutValue() throws java.sql.SQLException
Get the output parameter value.- Returns:
- the OUT value as an
Object
- Throws:
java.sql.SQLException
- if the parameter has not been set
-
setOutValue
void setOutValue(java.lang.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
java.lang.String getString(java.lang.String charset) throws java.io.IOException
Get the string value of the parameter.- Returns:
- The data value as a
String
or null. - Throws:
java.io.IOException
-
getBytes
byte[] getBytes(java.lang.String charset) throws java.io.IOException
Get the byte array value of the parameter.- Returns:
- The data value as a
byte[]
or null. - Throws:
java.io.IOException
-
loadFromStream
private static byte[] loadFromStream(java.io.InputStream in, int length) throws java.io.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:
java.io.IOException
-
loadFromReader
private static java.lang.String loadFromReader(java.io.Reader in, int length) throws java.io.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:
java.io.IOException
-
clone
public java.lang.Object clone()
Creates a shallow copy of thisParamInfo
instance. Used by thePreparedStatement
batching implementation to duplicate parameters.- Overrides:
clone
in classjava.lang.Object
-
-