public int denglu(String name,String password) throws ClassNotFoundException, SQLException { int flag=0;try{ java.sql.DriverManager.registerDriver(new com.mysql.j... 展开
public int denglu(String name,String password) throws ClassNotFoundException, SQLException { int flag=0;try{ java.sql.DriverManager.registerDriver(new com.mysql.jdbc.Driver());} catch(SQLException ex) { System.err.println("连接失败");System.exit(1);} String URL = "jdbc:mysql://localhost:3306/denglu";try{ Connection con = java.sql.DriverManager.getConnection(URL,"root","891123");String sql = "select ID from login where ID=? and mima=?";PreparedStatement stmt = con.prepareStatement(sql);stmt.setString(1,name);stmt.setString(2,password);ResultSet rs = stmt.executeQuery(sql);while (rs.next()) { //该用户合法 flag=1;} rs.close();stmt.close();con.close();} catch(SQLException e){System.out.print(e);} return flag;}不知道为什么会出现: You have an error in your SQL syntax;check the manual that corresponds to your MySQL 收起