DEFAULT_PRECISION_28
(package private) static final int DEFAULT_PRECISION_28
Default precision for SQL Server 6.5 and 7.
DEFAULT_PRECISION_38
(package private) static final int DEFAULT_PRECISION_38
Default precision for Sybase and SQL Server 2000 and newer.
DEFAULT_SCALE
(package private) static final int DEFAULT_SCALE
Default Decimal Scale.
MS_LONGVAR_MAX
private static final int MS_LONGVAR_MAX
SYBBINARY
private static final int SYBBINARY
SYBBIT
private static final int SYBBIT
SYBBITN
private static final int SYBBITN
SYBCHAR
private static final int SYBCHAR
SYBDATE
private static final int SYBDATE
SYBDATEN
private static final int SYBDATEN
SYBDATETIME
private static final int SYBDATETIME
SYBDATETIME4
private static final int SYBDATETIME4
SYBDATETIMN
private static final int SYBDATETIMN
SYBDECIMAL
private static final int SYBDECIMAL
SYBFLT8
private static final int SYBFLT8
SYBFLTN
private static final int SYBFLTN
SYBIMAGE
private static final int SYBIMAGE
SYBINT1
private static final int SYBINT1
SYBINT2
private static final int SYBINT2
SYBINT4
private static final int SYBINT4
SYBINT8
private static final int SYBINT8
SYBINTN
private static final int SYBINTN
SYBLONGBINARY
private static final int SYBLONGBINARY
SYBLONGDATA
(package private) static final int SYBLONGDATA
SYBMONEY
private static final int SYBMONEY
SYBMONEY4
private static final int SYBMONEY4
SYBMONEYN
private static final int SYBMONEYN
SYBNTEXT
private static final int SYBNTEXT
SYBNUMERIC
private static final int SYBNUMERIC
SYBNVARCHAR
private static final int SYBNVARCHAR
SYBREAL
private static final int SYBREAL
SYBSINT1
private static final int SYBSINT1
SYBSINT8
private static final int SYBSINT8
SYBTEXT
private static final int SYBTEXT
SYBTIME
private static final int SYBTIME
SYBTIMEN
private static final int SYBTIMEN
SYBUINT2
private static final int SYBUINT2
SYBUINT4
private static final int SYBUINT4
SYBUINT8
private static final int SYBUINT8
SYBUINTN
private static final int SYBUINTN
SYBUNIQUE
private static final int SYBUNIQUE
SYBUNITEXT
private static final int SYBUNITEXT
SYBVARBINARY
private static final int SYBVARBINARY
SYBVARCHAR
private static final int SYBVARCHAR
SYBVARIANT
private static final int SYBVARIANT
SYBVOID
private static final int SYBVOID
SYB_CHUNK_SIZE
private static final int SYB_CHUNK_SIZE
SYB_LONGVAR_MAX
private static final int SYB_LONGVAR_MAX
UDT_BINARY
private static final int UDT_BINARY
UDT_CHAR
private static final int UDT_CHAR
UDT_LONGSYSNAME
private static final int UDT_LONGSYSNAME
UDT_NCHAR
private static final int UDT_NCHAR
UDT_NEWSYSNAME
private static final int UDT_NEWSYSNAME
UDT_NVARCHAR
private static final int UDT_NVARCHAR
UDT_SYSNAME
private static final int UDT_SYSNAME
UDT_TIMESTAMP
private static final int UDT_TIMESTAMP
UDT_UNICHAR
private static final int UDT_UNICHAR
UDT_UNITEXT
private static final int UDT_UNITEXT
UDT_UNIVARCHAR
private static final int UDT_UNIVARCHAR
UDT_VARBINARY
private static final int UDT_VARBINARY
UDT_VARCHAR
private static final int UDT_VARCHAR
VAR_MAX
private static final int VAR_MAX
XSYBBINARY
private static final int XSYBBINARY
XSYBCHAR
private static final int XSYBCHAR
XSYBNCHAR
private static final int XSYBNCHAR
XSYBNVARCHAR
private static final int XSYBNVARCHAR
XSYBVARBINARY
private static final int XSYBVARBINARY
XSYBVARCHAR
private static final int XSYBVARCHAR
types
private static final TypeInfo[] types
Array of TDS data type descriptors.
canEncode
private static boolean canEncode(String value,
String charset)
Establish if a String can be converted to a byte based character set.
value
- The String to test.charset
- The server character set in force.
boolean
true if string can be converted.
fillInType
(package private) static void fillInType(ColInfo ci)
throws SQLException
Fill in the TDS native type code and all other fields for a
ColInfo
instance with the JDBC type set.
ci
- the ColInfo
instance
getCollation
(package private) static int getCollation(ResponseStream in,
ColInfo ci)
throws IOException
TDS 8 supplies collation information for character data types.
in
- the server response streamci
- the column descriptor
- the number of bytes read from the stream as an
int
getDatetimeValue
private static Object getDatetimeValue(ResponseStream in,
int type)
throws IOException,
ProtocolException
Get a DATETIME value from the server response stream.
in
- The server response stream.type
- The TDS data type.
- The java.sql.Timestamp value or null.
getMSTypeName
public static String getMSTypeName(String typeName,
int tdsType)
For SQL 2005 This routine will modify the meta data to allow the
caller to distinguish between varchar(max) and text or varbinary(max)
and image or nvarchar(max) and ntext.
typeName
- the SQL type returned by sp_columnstdsType
- the TDS type returned by sp_columns
- the (possibly) modified SQL type name as a
String
getMoneyValue
private static Object getMoneyValue(ResponseStream in,
int type)
throws IOException,
ProtocolException
Read a MONEY value from the server response stream.
in
- The server response stream.type
- The TDS data type.
- The java.math.BigDecimal value or null.
getNativeType
(package private) static void getNativeType(ConnectionJDBC2 connection,
ParamInfo pi)
throws SQLException
Retrieve the TDS native type code for the parameter.
connection
- the connectionJDBC objectpi
- the parameter descriptor
getTds5ParamSize
(package private) static int getTds5ParamSize(String charset,
boolean isWideChar,
ParamInfo pi,
boolean useParamNames)
Calculate the size of the parameter descriptor array for TDS 5 packets.
charset
- The encoding character set.isWideChar
- True if multi byte encoding.pi
- The parameter to describe.useParamNames
- True if named parameters should be used.
- The size of the parameter descriptor as an
int
.
getTdsVersion
public static int getTdsVersion(int rawTdsVersion)
Extract the TDS protocol version from the value returned by the server in the LOGINACK
packet.
rawTdsVersion
- the TDS protocol version as returned by the server
- the jTDS internal value for the protocol version (i.e one of the
Driver.TDSXX
values)
getVariant
private static Object getVariant(ConnectionJDBC2 connection,
ResponseStream in)
throws IOException,
ProtocolException
Read a MSQL 2000 sql_variant data value from the input stream.
SQL_VARIANT has the following structure:
- INT4 total size of data
- INT1 TDS data type (text/image/ntext/sql_variant not allowed)
- INT1 Length of extra type descriptor information
- Optional additional type info required by some types
- byte[0...n] the actual data
connection
- used to obtain collation/charset informationin
- the server response stream
isCollation
(package private) static boolean isCollation(ColInfo ci)
Retrieve the collation status of the column.
TDS 8.0 character columns include collation information.
ci
- the column meta data
true
if the column requires collation data.
isCurrency
(package private) static boolean isCurrency(ColInfo ci)
Retrieve the currency status of the column.
ci
- The column meta data.
boolean
true if the column is a currency type.
isSearchable
(package private) static boolean isSearchable(ColInfo ci)
Retrieve the searchable status of the column.
ci
- the column meta data
true
if the column is not a text or image type.
isSigned
(package private) static boolean isSigned(ColInfo ci)
Retrieve the signed status of the column.
ci
- the column meta data
true
if the column is a signed numeric.
isUnicode
(package private) static boolean isUnicode(ColInfo ci)
Determines whether the column is Unicode encoded.
ci
- the column meta data
true
if the column is Unicode encoded
putCollation
(package private) static void putCollation(RequestStream out,
ParamInfo pi)
throws IOException
TDS 8 requires collation information for char data descriptors.
out
- The Server request stream.pi
- The parameter descriptor.
putDateTimeValue
private static void putDateTimeValue(RequestStream out,
DateTime value)
throws IOException
Output a java.sql.Date/Time/Timestamp value to the server
as a Sybase datetime value.
out
- the server request streamvalue
- the date value to write
readData
(package private) static Object readData(ConnectionJDBC2 connection,
ResponseStream in,
ColInfo ci)
throws IOException,
ProtocolException
Read the TDS data item from the Response Stream.
The data size is either implicit in the type for example
fixed size integers, or a count field precedes the actual data.
The size of the count field varies with the data type.
connection
- an object reference to the caller of this method;
must be a Connection
, Statement
or
ResultSet
in
- The server ResponseStream.ci
- The ColInfo column descriptor object.
- The data item Object or null.
readType
(package private) static int readType(ResponseStream in,
ColInfo ci)
throws IOException,
ProtocolException
Read the TDS datastream and populate the ColInfo parameter with
data type and related information.
The type infomation conforms to one of the following formats:
- [int1 type] - eg SYBINT4.
- [int1 type] [int1 buffersize] - eg VARCHAR < 256
- [int1 type] [int2 buffersize] - eg VARCHAR > 255.
- [int1 type] [int4 buffersize] [int1 tabnamelen] [int1*n tabname] - eg text.
- [int1 type] [int4 buffersize] - eg sql_variant.
- [int1 type] [int1 buffersize] [int1 precision] [int1 scale] - eg decimal.
For TDS 8 large character types include a 5 byte collation field after the buffer size.
in
- The server response stream.ci
- The ColInfo column descriptor object.
- The number of bytes read from the input stream.
setColumnCharset
(package private) static void setColumnCharset(ColInfo ci,
ConnectionJDBC2 connection)
throws SQLException
Set the
charsetInfo
field of
ci
according to
the value of its
collation
field.
The
Connection
is used to find out whether a specific
charset was requested. In this case, the column charset will be ignored.
ci
- the ColInfo
instance to updateconnection
- a Connection
instance to check whether it
has a fixed charset or not
writeParam
(package private) static void writeParam(RequestStream out,
CharsetInfo charsetInfo,
byte[] collation,
ParamInfo pi)
throws IOException
Write a parameter to the server request stream.
out
- the server request streamcharsetInfo
- the default character setcollation
- the default SQL Server 2000 collationpi
- the parameter descriptor
writeTds5Param
(package private) static void writeTds5Param(RequestStream out,
CharsetInfo charsetInfo,
ParamInfo pi)
throws IOException,
SQLException
Write the actual TDS 5 parameter data.
out
- the server RequestStreamcharsetInfo
- the encoding character setpi
- the parameter to output
writeTds5ParamFmt
(package private) static void writeTds5ParamFmt(RequestStream out,
String charset,
boolean isWideChar,
ParamInfo pi,
boolean useParamNames)
throws IOException
Write a TDS 5 parameter format descriptor.
out
- The server RequestStream.charset
- The encoding character set.isWideChar
- True if multi byte encoding.pi
- The parameter to describe.useParamNames
- True if named parameters should be used.