日期:2014-05-20 浏览次数:20660 次
public static void main(String[] args) throws Exception{
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/test", "root", "root");
PreparedStatement ps = conn.prepareStatement("show variables like 'character%'");
ResultSet set = ps.executeQuery();
while(set.next()){
System.out.println(set.getString(1) + " : " + set.getString(2));
}
}
//打印结果:
character_set_client : gbk
character_set_connection : gbk
character_set_database : gbk
character_set_filesystem : binary
character_set_results :
character_set_server : gbk
character_set_system : utf8
character_sets_dir : C:\Program Files\MySQL\MySQL Server 5.5\share\charsets\