Java 和 SQL Server 支持的数据类型Java and SQL Server supported data types

适用于:Applies to: 是SQL Server 2019 (15.x)SQL Server 2019 (15.x)yesSQL Server 2019 (15.x)SQL Server 2019 (15.x)适用于:Applies to: 是SQL Server 2019 (15.x)SQL Server 2019 (15.x)yesSQL Server 2019 (15.x)SQL Server 2019 (15.x)

本文介绍如何针对数据结构和 sp_execute_external_script 上的参数将 SQL Server 数据类型映射到 Java 数据类型。This article maps SQL Server data types to Java data types for data structures and parameters on sp_execute_external_script.

输入/输出数据集和输入/输出参数当前支持以下 SQL 和 Java 数据类型。The following SQL and Java data types are currently supported for Input/Output data sets and Input/Output parameters.

SQL 数据类型SQL data type Java 数据类型Java data type 注释Comment
bitBit booleanboolean
TinyintTinyint shortshort
SmallintSmallint shortshort
IntInt intint
RealReal FLOATfloat
BigintBigint longlong
FLOATfloat doubledouble
nchar(n)nchar(n) StringString
nvarchar(n)nvarchar(n) StringString
binary(n)binary(n) byte[]byte[]
varbinary(n)varbinary(n) byte[]byte[]
nvarchar(max)nvarchar(max) StringString
varbinary(max)varbinary(max) byte[]byte[]
uniqueidentifieruniqueidentifier StringString
char(n)char(n) StringString 仅支持 UTF8 字符串Only UTF8 Strings supported
varchar(n)varchar(n) StringString 仅支持 UTF8 字符串Only UTF8 Strings supported
varchar(max)varchar(max) StringString 仅支持 UTF8 字符串Only UTF8 Strings supported
datedate java.sql.datejava.sql.date
numericnumeric java.math.BigDecimaljava.math.BigDecimal
Decimaldecimal java.math.BigDecimaljava.math.BigDecimal
moneymoney java.math.BigDecimaljava.math.BigDecimal
smallmoneysmallmoney java.math.BigDecimaljava.math.BigDecimal
smalldatetimesmalldatetime java.sql.timestampjava.sql.timestamp
datetimedatetime java.sql.timestampjava.sql.timestamp
datetime2datetime2 java.sql.timestampjava.sql.timestamp

后续步骤Next steps