what I want to do :
input sql statement, and get the column name set . like this :
select email as "邮件" from t_user
2.what I hava done:
String url = "jdbc:mysql://127.0.0.1:3306/testcode?useUnicode=true&characterEncoding=utf8";
Statement st = conn.createStatement();
st.setFetchSize(1);
ResultSet rs = st.executeQuery(sql);
ResultSetMetaData rmd = rs.getMetaData();
int columnCount = rmd.getColumnCount();
for (int i = 1; i <= columnCount; i++) {
String column = rmd.getColumnName(i);
}
- what's problem I got: the column name is garbage characters(except english letters),but the resultset is ok.