int decimalDigits=rs.getInt("DECIMAL_DIGITS");
// int numPrecRadix=rs.getInt("NUM_PREC_RADIX");
int nullable=rs.getInt("NULLABLE");
String remarks=rs.getString("REMARKS");
String columnDef=rs.getString("COLUMN_DEF");
MyField field=new MyField();
field.setFieldName(columnName);
field.setDataType(dataType);
field.setDbFieldType(typeName);
field.setFieldLength(columnSize);
field.setScale(decimalDigits);
field.setAllowNull(nullable==java.sql.DatabaseMetaData.columnNoNulls?false:true);
field.setDefaultValue(columnDef);
field.setRemarks(remarks);
fields.add(field);
}
//查询主键信息
rs2=metaData.getPrimaryKeys(conn.getCatalog(), metaData.getUserName(), tableName);
List keys=new ArrayList();
while(rs2.next()){
keys.add(rs2.getString("COLUMN_NAME"));
}
for(int i=0;i<fields.size();i++){
MyField f=(MyField) fields.get(i);
if(keys.contains(f.getFieldName())){
f.setKey(true);
}
}
} catch (Exception e) {
throw new RuntimeException("将表"+tableName+"的列转换为Field对象的时候出错",e);
} finally{