Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://:3305/test";
String user="root";
String pwd="admin";
Connection conn = DriverManager.getConnection(url, user, pwd);
Statement sm = conn.createStatement();
String sql = "select logname n, logpassword p from t_users";
ResultSet rs = sm.executeQuery(sql);
while (rs.next()){
System.out.print(rs.getString("n") + " ");
System.out.println(rs.getString("p"));
}
conn.close();
原文:https://www.cnblogs.com/argor/p/9172538.html