public static void test() throws Exception {
Connection conn=null;
String userName = "root";
String userPassword = "root";
String url = "jdbc:mysql://localhost:3306/fina?useUnicode=true&characterEncoding=utf8";
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection(url, userName, userPassword);
System.out.println(conn);
PreparedStatement ps=null;
ResultSet rs=null;
String sql="select id,name from tbl_user";
ps=conn.prepareStatement(sql);
rs=ps.executeQuery();
while(rs.next()){
System.out.println("ID:"+rs.getString(1)+"\t NAME:"+rs.getString(2));
}
if(null!=rs)
rs.close();
if(null!=ps)
ps.close();
if(null!=conn)
conn.close();
}