oracle/mysql java jdbc类型映射

java

MySQL数据类型JAVA数据类型JDBC TYPE普通变量类型主键类型
BIGINTLongBIGINT支持支持
TINYINTByteTINYINT支持不支持
SMALLINTShortSMALLINT支持不支持
MEDIUMINTIntegerINTEGER支持支持
INTEGERIntegerINTEGER支持支持
INTIntegerINTEGER支持支持
FLOATFloatREAL支持不支持
DOUBLEDoubleDOUBLE支持不支持
DECIMALBigDecimalDECIMAL支持不支持
NUMERICBigDecimalDECIMAL支持不支持
CHARStringCHAR支持不支持
VARCHARStringVARCHAR支持不支持
TINYBLOBDataTypeWithBLOBs.byte[]BINARY不支持不支持
TINYTEXTStringVARCHAR支持不支持
BLOBDataTypeWithBLOBs.byte[]BINARY不支持不支持
TEXTDataTypeWithBLOBs.StringLONGVARCHAR不支持不支持
MEDIUMBLOBDataTypeWithBLOBs.byte[]LONGVARBINARY不支持不支持
MEDIUMTEXTDataTypeWithBLOBs.StringLONGVARCHAR不支持不支持
LONGBLOBDataTypeWithBLOBs.byte[]LONGVARBINARY不支持不支持
LONGTEXTDataTypeWithBLOBs.StringLONGVARCHAR不支持不支持
DATEDateDATE支持不支持
TIMEDateTIME支持不支持
YEARDateDATE不支持不支持
DATETIMEDateTIMESTAMP支持不支持
TIMESTAMPDateTIMESTAMP支持不支持

  以下是商业数据库的。 

 java.sql.Types 值Java 类型IBM DB2OracleSybaseSQLInformixIBM Content Manager
 BIGINTjava.lang.longBIGINTNUMBER (38, 0)BIGINTBIGINTINT8DK_CM_BIGINT
 BINARYbyte[]CHAR FOR BIT DATARAWBINARYIMAGEBYTEDK_CM_BLOB
 BITjava.lang.BooleanN/ABITBITBITBITDK_CM_SMALLINT
 BLOBbyte[]BLOBBLOBBLOBBLOBBLOBDK_CM_BLOB
 CHARjava.lang.StringCHAR, GRAPHICCHARCHARCHARCHARDK_CM_CHAR
 CLOBjava.lang.StringCLOB, DBCLOBCLOBCLOBCLOBCLOBDK_CM_CLOB
 DATEjava.sql.DateDATEDATEDATEDATEDATEDK_CM_DATE
 DECIMALjava.math.BigDecimalDECIMALNUMBERDECIMAL, MONEY, SMALLMONEYDECIMALDECIMALDK_CM_DECIMAL
 DOUBLEjava.lang.DoubleDOUBLEDOUBLE PRECISIONDOUBLE PRECISIONDOUBLE PRECISIONDOUBLE PRECISIONDK_CM_DOUBLE
 FLOATjava.lang.DoubleFLOATFLOATFLOATFLOATFLOATDK_CM_DOUBLE
 INTEGERjava.lang.IntegerINTEGERINTEGERINTINTEGERINTEGERDK_CM_INTEGER
 JAVA_OBJECTjava.lang.ObjectJAVA_OBJECTJAVA_OBJECTJAVA_OBJECTJAVA_OBJECTOPAQUEN/A
 LONGVARBINARYbyte[]LONG VARCHAR FOR BIT DATALONG RAWIMAGEIMAGEBYTEDK_CM_BLOB
 LONGVARCHARjava.lang.StringLONG VARCHAR, LONG VARGRAPHICLONGTEXTTEXTTEXTDK_CM_VARCHAR(3500)
 NUMERICjava.math.BigDecimalNUMERICNUMBERNUMERICNUMERICNUMERICDK_CM_DECIMAL
 OTHERjava.lang.ObjectOTHEROTHEROTHEROTHEROTHERN/A
 REALjava.lang.FloatREALREALREALREALREALDK_CM_DOUBLE
 SMALLINTjava.lang.IntegerSMALLINTSMALLINTSMALLINTSMALLINTSMALLINTDK_CM_INTEGER
 TIMEjava.sql.TimeTIMEDATETIMETIMEDATETIME HOUR TO SECONDDK_CM_TIME
 TIMESTAMPjava.sql.TimestampTIMESTAMPDATEDATETIME, SMALLDATETIMEDATETIMEDATETIME YEAR TO FRACTION (5)DK_CM_TIMESTAMP
 TINYINTjava.lang.ButeSMALLINT

TINYINT

TINYINT

TINYINTTINYINTDK_CM_INTEGER
 VARBINARYbyte[]VARCHAR FOR BIT DATARAWVARBINARYIMAGEBYTEDK_CM_BLOB
 VARCHARjava.lang.StringVARCHAR, VARGRAPHICVARCHARVARCHARVARCHARVARCHARDK_CM_VARCHAR

 

  Oracle ResultSetMetaData getPrecision/getScale有一个bug,count(*) as xxx、abs(col) as xxx,这样xxx是无法返回正确的Scale和Precision的,要想这些情况下返回正确的值,需要使用明确的cast(xxx as datatype)。参见https://stackoverflow.com/questions/1410267/oracle-resultsetmetadata-getprecision-getscale

 java.sql.Types 值Java 类型IBM DB2OracleSybaseSQLInformixIBM Content Manager
 BIGINTjava.lang.longBIGINTNUMBER (38, 0)BIGINTBIGINTINT8DK_CM_BIGINT
 BINARYbyte[]CHAR FOR BIT DATARAWBINARYIMAGEBYTEDK_CM_BLOB
 BITjava.lang.BooleanN/ABITBITBITBITDK_CM_SMALLINT
 BLOBbyte[]BLOBBLOBBLOBBLOBBLOBDK_CM_BLOB
 CHARjava.lang.StringCHAR, GRAPHICCHARCHARCHARCHARDK_CM_CHAR
 CLOBjava.lang.StringCLOB, DBCLOBCLOBCLOBCLOBCLOBDK_CM_CLOB
 DATEjava.sql.DateDATEDATEDATEDATEDATEDK_CM_DATE
 DECIMALjava.math.BigDecimalDECIMALNUMBERDECIMAL, MONEY, SMALLMONEYDECIMALDECIMALDK_CM_DECIMAL
 DOUBLEjava.lang.DoubleDOUBLEDOUBLE PRECISIONDOUBLE PRECISIONDOUBLE PRECISIONDOUBLE PRECISIONDK_CM_DOUBLE
 FLOATjava.lang.DoubleFLOATFLOATFLOATFLOATFLOATDK_CM_DOUBLE
 INTEGERjava.lang.IntegerINTEGERINTEGERINTINTEGERINTEGERDK_CM_INTEGER
 JAVA_OBJECTjava.lang.ObjectJAVA_OBJECTJAVA_OBJECTJAVA_OBJECTJAVA_OBJECTOPAQUEN/A
 LONGVARBINARYbyte[]LONG VARCHAR FOR BIT DATALONG RAWIMAGEIMAGEBYTEDK_CM_BLOB
 LONGVARCHARjava.lang.StringLONG VARCHAR, LONG VARGRAPHICLONGTEXTTEXTTEXTDK_CM_VARCHAR(3500)
 NUMERICjava.math.BigDecimalNUMERICNUMBERNUMERICNUMERICNUMERICDK_CM_DECIMAL
 OTHERjava.lang.ObjectOTHEROTHEROTHEROTHEROTHERN/A
 REALjava.lang.FloatREALREALREALREALREALDK_CM_DOUBLE
 SMALLINTjava.lang.IntegerSMALLINTSMALLINTSMALLINTSMALLINTSMALLINTDK_CM_INTEGER
 TIMEjava.sql.TimeTIMEDATETIMETIMEDATETIME HOUR TO SECONDDK_CM_TIME
 TIMESTAMPjava.sql.TimestampTIMESTAMPDATEDATETIME, SMALLDATETIMEDATETIMEDATETIME YEAR TO FRACTION (5)DK_CM_TIMESTAMP
 TINYINTjava.lang.ButeSMALLINT

TINYINT

TINYINT

TINYINTTINYINTDK_CM_INTEGER
 VARBINARYbyte[]VARCHAR FOR BIT DATARAWVARBINARYIMAGEBYTEDK_CM_BLOB
 VARCHARjava.lang.StringVARCHAR, VARGRAPHICVARCHARVARCHARVARCHARVARCHARDK_CM_VARCHAR

以上是 oracle/mysql java jdbc类型映射 的全部内容, 来源链接: utcz.com/z/394392.html

回到顶部