The following table lists the default mappings between the basic SQL Server, JDBC, and Java programming language data types:
SQL Server Type |
JDBC Type (java.sql.Types) |
Java Language Types |
bigint |
BIGINT |
Long |
Timestamp Binary |
BINARY |
Byte[] |
Bit |
BIT |
Boolean |
Char |
CHAR |
String |
Decimal Money SmallMoney |
DECIMAL |
Java.math.BigDecimal |
Float |
DOUBLE |
Double |
Int |
INTEGER |
Int |
Image varbinary (max) |
LongVarBinary |
Byte[] |
varchar (max) Text |
LongVarChar |
String |
NChar |
CHAR NCHAR (Java SE 6.0) |
String |
nvarchar |
VARCHAR NVARCHAR (Java SE 6.0) |
String |
nvarchar (max) ntext |
LongVarChar Longnvarchar (Java SE 6.0) |
String |
Numeric |
NUMERIC |
Java.math.BigDecimal |
Real |
REAL |
Float |
smallint |
SMALLINT |
Short |
Datetime smalldatetime |
TIMESTAMP |
Java.sql.Timestamp |
varbinary Udt |
VARBINARY |
Byte[] |
varchar |
VARCHAR |
String |
tinyint |
TINYINT |
Short |
uniqueidentifier |
CHAR |
String |
Xml |
LongVarChar SQLXML (Java SE 6.0) |
String SQLXML |
Time |
Time (1) |
Java.sql.Time (1) |
Date |
DATE |
Java.sql.Date |
DateTime2 |
TIMESTAMP |
Java.sql.Timestamp |
DateTimeOffset (2) |
Microsoft.sql.Types.DATETIMEOFFSET |
Microsoft.sql.DateTimeOffset |
SQL Server database type corresponds to data type in Java