|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.jtds.jdbc.TdsData
Implement TDS data types and related I/O logic.
Implementation notes:
Nested Class Summary | |
private static class |
TdsData.TypeInfo
This class implements a descriptor for TDS data types; |
Field Summary | |
(package private) static int |
DEFAULT_PRECISION_28
Default precision for SQL Server 6.5 and 7. |
(package private) static int |
DEFAULT_PRECISION_38
Default precision for Sybase and SQL Server 2000 and newer. |
(package private) static int |
DEFAULT_SCALE
Default Decimal Scale. |
private static int |
MS_LONGVAR_MAX
|
private static int |
SYB_CHUNK_SIZE
|
private static int |
SYB_LONGVAR_MAX
|
private static int |
SYBBINARY
|
private static int |
SYBBIT
|
private static int |
SYBBITN
|
private static int |
SYBCHAR
|
private static int |
SYBDATE
|
private static int |
SYBDATEN
|
private static int |
SYBDATETIME
|
private static int |
SYBDATETIME4
|
private static int |
SYBDATETIMN
|
private static int |
SYBDECIMAL
|
private static int |
SYBFLT8
|
private static int |
SYBFLTN
|
private static int |
SYBIMAGE
|
private static int |
SYBINT1
|
private static int |
SYBINT2
|
private static int |
SYBINT4
|
private static int |
SYBINT8
|
private static int |
SYBINTN
|
private static int |
SYBLONGBINARY
|
(package private) static int |
SYBLONGDATA
|
private static int |
SYBMONEY
|
private static int |
SYBMONEY4
|
private static int |
SYBMONEYN
|
private static int |
SYBNTEXT
|
private static int |
SYBNUMERIC
|
private static int |
SYBNVARCHAR
|
private static int |
SYBREAL
|
private static int |
SYBSINT1
|
private static int |
SYBSINT8
|
private static int |
SYBTEXT
|
private static int |
SYBTIME
|
private static int |
SYBTIMEN
|
private static int |
SYBUINT2
|
private static int |
SYBUINT4
|
private static int |
SYBUINT8
|
private static int |
SYBUINTN
|
private static int |
SYBUNIQUE
|
private static int |
SYBUNITEXT
|
private static int |
SYBVARBINARY
|
private static int |
SYBVARCHAR
|
private static int |
SYBVARIANT
|
private static int |
SYBVOID
|
private static TdsData.TypeInfo[] |
types
Array of TDS data type descriptors. |
private static int |
UDT_BINARY
|
private static int |
UDT_CHAR
|
private static int |
UDT_LONGSYSNAME
|
private static int |
UDT_NCHAR
|
private static int |
UDT_NEWSYSNAME
|
private static int |
UDT_NVARCHAR
|
private static int |
UDT_SYSNAME
|
private static int |
UDT_TIMESTAMP
|
private static int |
UDT_UNICHAR
|
private static int |
UDT_UNITEXT
|
private static int |
UDT_UNIVARCHAR
|
private static int |
UDT_VARBINARY
|
private static int |
UDT_VARCHAR
|
private static int |
VAR_MAX
|
private static int |
XSYBBINARY
|
private static int |
XSYBCHAR
|
private static int |
XSYBNCHAR
|
private static int |
XSYBNVARCHAR
|
private static int |
XSYBVARBINARY
|
private static int |
XSYBVARCHAR
|
Constructor Summary | |
private |
TdsData()
Private constructor to prevent users creating an actual instance of this class. |
Method Summary | |
private static boolean |
canEncode(java.lang.String value,
java.lang.String charset)
Establish if a String can be converted to a byte based character set. |
(package private) static void |
fillInType(ColInfo ci)
Fill in the TDS native type code and all other fields for a ColInfo instance with the JDBC type set. |
(package private) static int |
getCollation(ResponseStream in,
ColInfo ci)
TDS 8 supplies collation information for character data types. |
private static java.lang.Object |
getDatetimeValue(ResponseStream in,
int type)
Get a DATETIME value from the server response stream. |
private static java.lang.Object |
getMoneyValue(ResponseStream in,
int type)
Read a MONEY value from the server response stream. |
static java.lang.String |
getMSTypeName(java.lang.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. |
(package private) static void |
getNativeType(ConnectionJDBC2 connection,
ParamInfo pi)
Retrieve the TDS native type code for the parameter. |
(package private) static int |
getTds5ParamSize(java.lang.String charset,
boolean isWideChar,
ParamInfo pi,
boolean useParamNames)
Calculate the size of the parameter descriptor array for TDS 5 packets. |
static int |
getTdsVersion(int rawTdsVersion)
Extract the TDS protocol version from the value returned by the server in the LOGINACK packet. |
private static java.lang.Object |
getVariant(ConnectionJDBC2 connection,
ResponseStream in)
Read a MSQL 2000 sql_variant data value from the input stream. |
(package private) static boolean |
isCollation(ColInfo ci)
Retrieve the collation status of the column. |
(package private) static boolean |
isCurrency(ColInfo ci)
Retrieve the currency status of the column. |
(package private) static boolean |
isSearchable(ColInfo ci)
Retrieve the searchable status of the column. |
(package private) static boolean |
isSigned(ColInfo ci)
Retrieve the signed status of the column. |
(package private) static boolean |
isUnicode(ColInfo ci)
Determines whether the column is Unicode encoded. |
(package private) static void |
putCollation(RequestStream out,
ParamInfo pi)
TDS 8 requires collation information for char data descriptors. |
private static void |
putDateTimeValue(RequestStream out,
DateTime value)
Output a java.sql.Date/Time/Timestamp value to the server as a Sybase datetime value. |
(package private) static java.lang.Object |
readData(ConnectionJDBC2 connection,
ResponseStream in,
ColInfo ci)
Read the TDS data item from the Response Stream. |
(package private) static int |
readType(ResponseStream in,
ColInfo ci)
Read the TDS datastream and populate the ColInfo parameter with data type and related information. |
(package private) static void |
setColumnCharset(ColInfo ci,
ConnectionJDBC2 connection)
Set the charsetInfo field of ci according to
the value of its collation field.
|
(package private) static void |
writeParam(RequestStream out,
CharsetInfo charsetInfo,
byte[] collation,
ParamInfo pi)
Write a parameter to the server request stream. |
(package private) static void |
writeTds5Param(RequestStream out,
CharsetInfo charsetInfo,
ParamInfo pi)
Write the actual TDS 5 parameter data. |
(package private) static void |
writeTds5ParamFmt(RequestStream out,
java.lang.String charset,
boolean isWideChar,
ParamInfo pi,
boolean useParamNames)
Write a TDS 5 parameter format descriptor. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final int SYBCHAR
private static final int SYBVARCHAR
private static final int SYBINTN
private static final int SYBINT1
private static final int SYBDATE
private static final int SYBTIME
private static final int SYBINT2
private static final int SYBINT4
private static final int SYBINT8
private static final int SYBFLT8
private static final int SYBDATETIME
private static final int SYBBIT
private static final int SYBTEXT
private static final int SYBNTEXT
private static final int SYBIMAGE
private static final int SYBMONEY4
private static final int SYBMONEY
private static final int SYBDATETIME4
private static final int SYBREAL
private static final int SYBBINARY
private static final int SYBVOID
private static final int SYBVARBINARY
private static final int SYBNVARCHAR
private static final int SYBBITN
private static final int SYBNUMERIC
private static final int SYBDECIMAL
private static final int SYBFLTN
private static final int SYBMONEYN
private static final int SYBDATETIMN
private static final int SYBDATEN
private static final int SYBTIMEN
private static final int XSYBCHAR
private static final int XSYBVARCHAR
private static final int XSYBNVARCHAR
private static final int XSYBNCHAR
private static final int XSYBVARBINARY
private static final int XSYBBINARY
private static final int SYBUNITEXT
private static final int SYBLONGBINARY
private static final int SYBSINT1
private static final int SYBUINT2
private static final int SYBUINT4
private static final int SYBUINT8
private static final int SYBUINTN
private static final int SYBUNIQUE
private static final int SYBVARIANT
private static final int SYBSINT8
static final int SYBLONGDATA
private static final int UDT_CHAR
private static final int UDT_VARCHAR
private static final int UDT_BINARY
private static final int UDT_VARBINARY
private static final int UDT_SYSNAME
private static final int UDT_NCHAR
private static final int UDT_NVARCHAR
private static final int UDT_UNICHAR
private static final int UDT_UNIVARCHAR
private static final int UDT_UNITEXT
private static final int UDT_LONGSYSNAME
private static final int UDT_TIMESTAMP
private static final int UDT_NEWSYSNAME
private static final int VAR_MAX
private static final int SYB_LONGVAR_MAX
private static final int MS_LONGVAR_MAX
private static final int SYB_CHUNK_SIZE
private static final TdsData.TypeInfo[] types
static final int DEFAULT_SCALE
static final int DEFAULT_PRECISION_28
static final int DEFAULT_PRECISION_38
Constructor Detail |
private TdsData()
Method Detail |
static int getCollation(ResponseStream in, ColInfo ci) throws java.io.IOException
in
- the server response streamci
- the column descriptor
int
java.io.IOException
static void setColumnCharset(ColInfo ci, ConnectionJDBC2 connection) throws java.sql.SQLException
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
java.sql.SQLException
- if a CharsetInfo
is not found for this
particular column collationstatic int readType(ResponseStream in, ColInfo ci) throws java.io.IOException, ProtocolException
The type infomation conforms to one of the following formats:
in
- The server response stream.ci
- The ColInfo column descriptor object.
java.io.IOException
ProtocolException
static java.lang.Object readData(ConnectionJDBC2 connection, ResponseStream in, ColInfo ci) throws java.io.IOException, ProtocolException
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.
java.io.IOException
ProtocolException
static boolean isSigned(ColInfo ci)
ci
- the column meta data
true
if the column is a signed numeric.static boolean isCollation(ColInfo ci)
ci
- the column meta data
true
if the column requires collation data.static boolean isCurrency(ColInfo ci)
ci
- The column meta data.
boolean
true if the column is a currency type.static boolean isSearchable(ColInfo ci)
ci
- the column meta data
true
if the column is not a text or image type.static boolean isUnicode(ColInfo ci)
ci
- the column meta data
true
if the column is Unicode encodedstatic void fillInType(ColInfo ci) throws java.sql.SQLException
ColInfo
instance with the JDBC type set.
ci
- the ColInfo
instance
java.sql.SQLException
static void getNativeType(ConnectionJDBC2 connection, ParamInfo pi) throws java.sql.SQLException
connection
- the connectionJDBC objectpi
- the parameter descriptor
java.sql.SQLException
static int getTds5ParamSize(java.lang.String charset, boolean isWideChar, ParamInfo pi, boolean useParamNames)
charset
- The encoding character set.isWideChar
- True if multi byte encoding.pi
- The parameter to describe.useParamNames
- True if named parameters should be used.
int
.static void writeTds5ParamFmt(RequestStream out, java.lang.String charset, boolean isWideChar, ParamInfo pi, boolean useParamNames) throws java.io.IOException
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.
java.io.IOException
static void writeTds5Param(RequestStream out, CharsetInfo charsetInfo, ParamInfo pi) throws java.io.IOException, java.sql.SQLException
out
- the server RequestStreamcharsetInfo
- the encoding character setpi
- the parameter to output
java.io.IOException
java.sql.SQLException
static void putCollation(RequestStream out, ParamInfo pi) throws java.io.IOException
out
- The Server request stream.pi
- The parameter descriptor.
java.io.IOException
static void writeParam(RequestStream out, CharsetInfo charsetInfo, byte[] collation, ParamInfo pi) throws java.io.IOException
out
- the server request streamcharsetInfo
- the default character setcollation
- the default SQL Server 2000 collationpi
- the parameter descriptor
java.io.IOException
private static java.lang.Object getDatetimeValue(ResponseStream in, int type) throws java.io.IOException, ProtocolException
in
- The server response stream.type
- The TDS data type.
java.io.IOException
ProtocolException
private static void putDateTimeValue(RequestStream out, DateTime value) throws java.io.IOException
out
- the server request streamvalue
- the date value to write
java.io.IOException
private static java.lang.Object getMoneyValue(ResponseStream in, int type) throws java.io.IOException, ProtocolException
in
- The server response stream.type
- The TDS data type.
java.io.IOException
ProtocolException
private static java.lang.Object getVariant(ConnectionJDBC2 connection, ResponseStream in) throws java.io.IOException, ProtocolException
SQL_VARIANT has the following structure:
connection
- used to obtain collation/charset informationin
- the server response stream
java.io.IOException
ProtocolException
public static java.lang.String getMSTypeName(java.lang.String typeName, int tdsType)
typeName
- the SQL type returned by sp_columnstdsType
- the TDS type returned by sp_columns
String
public static int getTdsVersion(int rawTdsVersion)
rawTdsVersion
- the TDS protocol version as returned by the server
Driver.TDSXX
values)private static boolean canEncode(java.lang.String value, java.lang.String charset)
value
- The String to test.charset
- The server character set in force.
boolean
true if string can be converted.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |