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.CloneableThis 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) CharsetInfocharsetInfoCharacter set descriptor (if different from default)(package private) byte[]collationTDS 8 Collation string.(package private) static intINPUTFlag as an input parameter.(package private) booleanisOutputParameter is an output parameter(package private) booleanisRetValParameter is used as SP return value(package private) booleanisSetIN parameter has been set(package private) booleanisSetOutOUT parameter value is set.(package private) booleanisUnicodeParameter should be sent as unicode(package private) intjdbcTypeJDBC type constant from java.sql.Types(package private) intlengthLength of InputStream(package private) intmarkerPosParameter offset in target SQL statement(package private) java.lang.StringnameFormal parameter name eg @P1(package private) static intOUTPUTFlag as an output parameter.(package private) java.lang.ObjectoutValueOUT Parameter value.(package private) intprecisionParameter decimal precision(package private) static intRETVALFlag as an return value parameter.(package private) intscaleParameter decimal scale(package private) java.lang.StringsqlTypeSQL type name eg varchar(10)(package private) inttdsTypeInternal TDS data type(package private) static intUNICODEFlag as a unicode parameter.(package private) java.lang.ObjectvalueCurrent 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) voidclearInValue()Clear the IN parameter value and status.(package private) voidclearOutValue()Clear the OUT parameter value and status.java.lang.Objectclone()Creates a shallow copy of thisParamInfoinstance.(package private) byte[]getBytes(java.lang.String charset)Get the byte array value of the parameter.(package private) java.lang.ObjectgetOutValue()Get the output parameter value.(package private) java.lang.StringgetString(java.lang.String charset)Get the string value of the parameter.private static java.lang.StringloadFromReader(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) voidsetOutValue(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-trueif 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-trueif the parameter is a return valueisUnicode-trueif 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.Typeconstant 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.SQLExceptionGet 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.IOExceptionGet the string value of the parameter.- Returns:
- The data value as a
Stringor null. - Throws:
java.io.IOException
-
getBytes
byte[] getBytes(java.lang.String charset) throws java.io.IOExceptionGet 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.IOExceptionLoad 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.IOExceptionCreate 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 thisParamInfoinstance. Used by thePreparedStatementbatching implementation to duplicate parameters.- Overrides:
clonein classjava.lang.Object
-
-