日期:2014-05-20 浏览次数:20701 次
try { //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Class.forName("com.mysql.jdbc.Driver"); } catch(ClassNotFoundException e2){} try { //Connection con = DriverManager.getConnection("jdbc:odbc:mail"); Connection con = DriverManager.getConnection("jdbc:mysql://208.81.166.169:3306/hythzxSQL","hythzxSQL","727799796"); Statement stmt = con.createStatement(); String sql = "SELECT user,password FROM log"; ResultSet rs = stmt.executeQuery(sql); while (rs.next()) { name=rs.getString("user"); password=rs.getString("password"); boolean name_password1=tf1.getText().equals(name); boolean name_password2=tf2.getText().equals(password); if(name_password1==true &&name_password2==true) { System.out.println("登录成功!"); } else { System.out.println("用户名或密码错误!"); } } rs.close(); stmt.close(); con.close(); } catch(Exception e3){}