oracle/mysql java jdbc类型映射
MySQL数据类型 | JAVA数据类型 | JDBC TYPE | 普通变量类型 | 主键类型 |
---|---|---|---|---|
BIGINT | Long | BIGINT | 支持 | 支持 |
TINYINT | Byte | TINYINT | 支持 | 不支持 |
SMALLINT | Short | SMALLINT | 支持 | 不支持 |
MEDIUMINT | Integer | INTEGER | 支持 | 支持 |
INTEGER | Integer | INTEGER | 支持 | 支持 |
INT | Integer | INTEGER | 支持 | 支持 |
FLOAT | Float | REAL | 支持 | 不支持 |
DOUBLE | Double | DOUBLE | 支持 | 不支持 |
DECIMAL | BigDecimal | DECIMAL | 支持 | 不支持 |
NUMERIC | BigDecimal | DECIMAL | 支持 | 不支持 |
CHAR | String | CHAR | 支持 | 不支持 |
VARCHAR | String | VARCHAR | 支持 | 不支持 |
TINYBLOB | DataTypeWithBLOBs.byte[] | BINARY | 不支持 | 不支持 |
TINYTEXT | String | VARCHAR | 支持 | 不支持 |
BLOB | DataTypeWithBLOBs.byte[] | BINARY | 不支持 | 不支持 |
TEXT | DataTypeWithBLOBs.String | LONGVARCHAR | 不支持 | 不支持 |
MEDIUMBLOB | DataTypeWithBLOBs.byte[] | LONGVARBINARY | 不支持 | 不支持 |
MEDIUMTEXT | DataTypeWithBLOBs.String | LONGVARCHAR | 不支持 | 不支持 |
LONGBLOB | DataTypeWithBLOBs.byte[] | LONGVARBINARY | 不支持 | 不支持 |
LONGTEXT | DataTypeWithBLOBs.String | LONGVARCHAR | 不支持 | 不支持 |
DATE | Date | DATE | 支持 | 不支持 |
TIME | Date | TIME | 支持 | 不支持 |
YEAR | Date | DATE | 不支持 | 不支持 |
DATETIME | Date | TIMESTAMP | 支持 | 不支持 |
TIMESTAMP | Date | TIMESTAMP | 支持 | 不支持 |
以下是商业数据库的。
java.sql.Types 值 | Java 类型 | IBM DB2 | Oracle | Sybase | SQL | Informix | IBM Content Manager | |
BIGINT | java.lang.long | BIGINT | NUMBER (38, 0) | BIGINT | BIGINT | INT8 | DK_CM_BIGINT | |
BINARY | byte[] | CHAR FOR BIT DATA | RAW | BINARY | IMAGE | BYTE | DK_CM_BLOB | |
BIT | java.lang.Boolean | N/A | BIT | BIT | BIT | BIT | DK_CM_SMALLINT | |
BLOB | byte[] | BLOB | BLOB | BLOB | BLOB | BLOB | DK_CM_BLOB | |
CHAR | java.lang.String | CHAR, GRAPHIC | CHAR | CHAR | CHAR | CHAR | DK_CM_CHAR | |
CLOB | java.lang.String | CLOB, DBCLOB | CLOB | CLOB | CLOB | CLOB | DK_CM_CLOB | |
DATE | java.sql.Date | DATE | DATE | DATE | DATE | DATE | DK_CM_DATE | |
DECIMAL | java.math.BigDecimal | DECIMAL | NUMBER | DECIMAL, MONEY, SMALLMONEY | DECIMAL | DECIMAL | DK_CM_DECIMAL | |
DOUBLE | java.lang.Double | DOUBLE | DOUBLE PRECISION | DOUBLE PRECISION | DOUBLE PRECISION | DOUBLE PRECISION | DK_CM_DOUBLE | |
FLOAT | java.lang.Double | FLOAT | FLOAT | FLOAT | FLOAT | FLOAT | DK_CM_DOUBLE | |
INTEGER | java.lang.Integer | INTEGER | INTEGER | INT | INTEGER | INTEGER | DK_CM_INTEGER | |
JAVA_OBJECT | java.lang.Object | JAVA_OBJECT | JAVA_OBJECT | JAVA_OBJECT | JAVA_OBJECT | OPAQUE | N/A | |
LONGVARBINARY | byte[] | LONG VARCHAR FOR BIT DATA | LONG RAW | IMAGE | IMAGE | BYTE | DK_CM_BLOB | |
LONGVARCHAR | java.lang.String | LONG VARCHAR, LONG VARGRAPHIC | LONG | TEXT | TEXT | TEXT | DK_CM_VARCHAR(3500) | |
NUMERIC | java.math.BigDecimal | NUMERIC | NUMBER | NUMERIC | NUMERIC | NUMERIC | DK_CM_DECIMAL | |
OTHER | java.lang.Object | OTHER | OTHER | OTHER | OTHER | OTHER | N/A | |
REAL | java.lang.Float | REAL | REAL | REAL | REAL | REAL | DK_CM_DOUBLE | |
SMALLINT | java.lang.Integer | SMALLINT | SMALLINT | SMALLINT | SMALLINT | SMALLINT | DK_CM_INTEGER | |
TIME | java.sql.Time | TIME | DATE | TIME | TIME | DATETIME HOUR TO SECOND | DK_CM_TIME | |
TIMESTAMP | java.sql.Timestamp | TIMESTAMP | DATE | DATETIME, SMALLDATETIME | DATETIME | DATETIME YEAR TO FRACTION (5) | DK_CM_TIMESTAMP | |
TINYINT | java.lang.Bute | SMALLINT | TINYINT | TINYINT | TINYINT | TINYINT | DK_CM_INTEGER | |
VARBINARY | byte[] | VARCHAR FOR BIT DATA | RAW | VARBINARY | IMAGE | BYTE | DK_CM_BLOB | |
VARCHAR | java.lang.String | VARCHAR, VARGRAPHIC | VARCHAR | VARCHAR | VARCHAR | VARCHAR | DK_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 DB2 | Oracle | Sybase | SQL | Informix | IBM Content Manager | |
BIGINT | java.lang.long | BIGINT | NUMBER (38, 0) | BIGINT | BIGINT | INT8 | DK_CM_BIGINT | |
BINARY | byte[] | CHAR FOR BIT DATA | RAW | BINARY | IMAGE | BYTE | DK_CM_BLOB | |
BIT | java.lang.Boolean | N/A | BIT | BIT | BIT | BIT | DK_CM_SMALLINT | |
BLOB | byte[] | BLOB | BLOB | BLOB | BLOB | BLOB | DK_CM_BLOB | |
CHAR | java.lang.String | CHAR, GRAPHIC | CHAR | CHAR | CHAR | CHAR | DK_CM_CHAR | |
CLOB | java.lang.String | CLOB, DBCLOB | CLOB | CLOB | CLOB | CLOB | DK_CM_CLOB | |
DATE | java.sql.Date | DATE | DATE | DATE | DATE | DATE | DK_CM_DATE | |
DECIMAL | java.math.BigDecimal | DECIMAL | NUMBER | DECIMAL, MONEY, SMALLMONEY | DECIMAL | DECIMAL | DK_CM_DECIMAL | |
DOUBLE | java.lang.Double | DOUBLE | DOUBLE PRECISION | DOUBLE PRECISION | DOUBLE PRECISION | DOUBLE PRECISION | DK_CM_DOUBLE | |
FLOAT | java.lang.Double | FLOAT | FLOAT | FLOAT | FLOAT | FLOAT | DK_CM_DOUBLE | |
INTEGER | java.lang.Integer | INTEGER | INTEGER | INT | INTEGER | INTEGER | DK_CM_INTEGER | |
JAVA_OBJECT | java.lang.Object | JAVA_OBJECT | JAVA_OBJECT | JAVA_OBJECT | JAVA_OBJECT | OPAQUE | N/A | |
LONGVARBINARY | byte[] | LONG VARCHAR FOR BIT DATA | LONG RAW | IMAGE | IMAGE | BYTE | DK_CM_BLOB | |
LONGVARCHAR | java.lang.String | LONG VARCHAR, LONG VARGRAPHIC | LONG | TEXT | TEXT | TEXT | DK_CM_VARCHAR(3500) | |
NUMERIC | java.math.BigDecimal | NUMERIC | NUMBER | NUMERIC | NUMERIC | NUMERIC | DK_CM_DECIMAL | |
OTHER | java.lang.Object | OTHER | OTHER | OTHER | OTHER | OTHER | N/A | |
REAL | java.lang.Float | REAL | REAL | REAL | REAL | REAL | DK_CM_DOUBLE | |
SMALLINT | java.lang.Integer | SMALLINT | SMALLINT | SMALLINT | SMALLINT | SMALLINT | DK_CM_INTEGER | |
TIME | java.sql.Time | TIME | DATE | TIME | TIME | DATETIME HOUR TO SECOND | DK_CM_TIME | |
TIMESTAMP | java.sql.Timestamp | TIMESTAMP | DATE | DATETIME, SMALLDATETIME | DATETIME | DATETIME YEAR TO FRACTION (5) | DK_CM_TIMESTAMP | |
TINYINT | java.lang.Bute | SMALLINT | TINYINT | TINYINT | TINYINT | TINYINT | DK_CM_INTEGER | |
VARBINARY | byte[] | VARCHAR FOR BIT DATA | RAW | VARBINARY | IMAGE | BYTE | DK_CM_BLOB | |
VARCHAR | java.lang.String | VARCHAR, VARGRAPHIC | VARCHAR | VARCHAR | VARCHAR | VARCHAR | DK_CM_VARCHAR |
以上是 oracle/mysql java jdbc类型映射 的全部内容, 来源链接: utcz.com/z/394392.html