ResultSetMetaData类的getColumnTypeName方法:public String getColumnTypeName(int column) throws SQLException Retrieves the designated column's database-specific type name.Parameters:column - the first column is 1, the second is 2, ...Returns:type name used by the database. If the column type is a user-defined type, then a fully-qualified type name is returned.Throws:SQLException - if a database access error occ
throws SQLException
Retrieves the designated column's database-specific type name.Parameters:column - the first column is 1, the second is 2, ...Returns:type name used by the database. If the column type is a user-defined type, then a fully-qualified type name is returned.Throws:SQLException - if a database access error occ
DatabaseMetaData dbmd=con.getMetaData();
ResultSet rsTable = dbmd.getColumns(null,null,"datakind",null);
这样 rsTable.getString("data_type") 就可以得到当前字段的数据类型了--datetime,nchar;通过这个方法:
rsTable=stmtStmt.executeQuery("select * form tablename");
ResultSetMetaData rsmd=rsTable.getMetaData();
通过 rsmd.getColumnClassName(i)就得到了第i个字段的ClassName--java.lang.String我的问题是:现在我只要得到tablename中各个字段的ClassName,如果通过ResultSetMetaData得到,那么首先我得进行一步不必要的查询返回记录集,有什么办法可以直接得到ClassName吗?希望这次的描述清楚一些。