我在oracle中创建下表:
CREATE TABLE TEST
(
DKEY INTEGER NOT NULL PRIMARY KEY,
NOM VARCHAR2(255) NOT NULL
)
当我尝试使用此java代码获取DKEY字段的类型时,我得到以下结果:
DatabaseMetaData md = cnx.getMetaData();
ResultSet rsmd = md.getColumns(null, strSchema, strTableName, "%");
while (rsmd != null && rsmd.next()) {
String strTmp = rsmd.getString("SQL_DATA_TYPE"); // this return 0 for field DKEY
int intDType = rsmd.getInt("DATA_TYPE"); // this return 3 for field DKEY
String strFType = rsmd.getString("TYPE_NAME") // this return NUMBER for field DKEY
}
为什么我得到NUMBER而不是INTEGER?
答案 0 :(得分:5)
答案 1 :(得分:0)
我认为表格列DKEY属性类型是NUMBER
但是试试
while (rsmd != null && rsmd.next()) {
String strTmp = rsmd.getString("SQL_DATA_TYPE"); // this return 0 for field DKEY
int intDType = Integer.parseInt(rsmd.getLong("DATA_TYPE")); // this return 3 for field DKEY
String strFType = rsmd.getString("TYPE_NAME") // this return NUMBER for field DKEY
}