Connection conn = driver.connect(url, info);
Statement statement = conn.createStatement();
ResultSet re = statement.executeQuery("select id as `主键`,user_name as `名字` from user");
ResultSetMetaData metaData = re.getMetaData();
for(int i=1;i<=metaData.getColumnCount();i++){
System.out.println(metaData.getColumnLabel(i)+" "+metaData.getColumnName(i)+" "
+metaData.getColumnType(i)+" "+metaData.getColumnTypeName(i));
}
?? id 4 INT
?? user_name 12 VARCHAR
解决办法 :url添加编码
private static String url = "jdbc:mysql://localhost:3307/test?useUnicode=true&characterEncoding=UTF-8";