当我尝试使用类型和的方法获取列类型时,ResultSetMetaData
我得到
. 对于其他类型,它似乎工作正常。这是一个错误吗?似乎没问题。我正在运行getColumnTypeName
date
time(x)
nvarchar
ResultSet
getString("TYPE_NAME")
MSSQL2008
@a_horse_with_no_name
ResultSetMetaData
我在执行查询时得到。在那种情况下,我没有任何桌子。这是代码片段
if (resultType == ResultMappingType.QUERY){ // For Query
Statement statement = con.createStatement();
ResultSet rs = executeAndValidateQuery(statement, resultName);
ResultSetMetaData rsMeta = rs.getMetaData();
for( int i = 1 ; i < rsMeta.getColumnCount()+1 ; i ++ ){
columnInfo.put( rsMeta.getColumnName(i), rsMeta.getColumnTypeName(i));
}
}else { //For View & Table
ResultSet rsColumns = meta.getColumns(catalog, schemaPattern, resultName, null);
while (rsColumns.next()){
columnInfo.put(rsColumns.getString("COLUMN_NAME"), rsColumns.getString("TYPE_NAME"));
}
}
....
private ResultSet executeAndValidateQuery(Statement statement, String query) throws KbValidationException{
ResultSet rs = null;
try{
rs = statement.executeQuery(query);
}
catch(SQLException ex){
throw new KbValidationException(ex.getMessage());
}
return rs;
}