我想做什么:
输入sql语句,并获取列名设置。像这样:
从t_user
2.我做了什么:
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);
}