getColumnName乱码
我用getColumnName提取字段名,但显示是乱码,但是我用getString则能显示正确的中文数据值,我的数据库是mysql5,请问各位高手如何解决,万分感谢!
代码如下:
Str_sql= "select f1 as `字段1`,f2 as `字段2` from t1 ";
ResultSet rs=stmt.executeQuery(Str_sql);
ResultSetMetaData rsmd=rs.getMetaData();
for ( j = 1;j <=rsmd.getColumnCount();j++)
{ out.print( " <TD> "+rsmd.getColumnName(j)+ " </TD> ");}
for ( j = 1;j <=rsmd.getColumnCount();j++)
{ out.print( " <TD> "+rs.getString(j)+ " </TD> ");
}
------解决方案--------------------别用中文吧。