@WebMethod(operationName = "operation")
public String operation(@WebParam(name = "username") String username, @WebParam(name = "password") String password){
String message = "";
try {
Connection connection;
PreparedStatement ps;
connection = DriverManager.getConnection("jdbc:mysql://localhost/banksystem", "root", "");
ps = connection.prepareStatement("SELECT `username`,`password` FROM `banklogin` WHERE `username`=? AND `password`=?");
ps.setString(1, username);
ps.setString(2, password);
ResultSet result = ps.executeQuery();
if(result.next()){
message = "Login Successful!";
}else{
message = "Login Failed!";
}
} catch (SQLException ex) {
Logger.getLogger(login.class.getName()).log(Level.SEVERE, null, ex);
}
return message;
}
}
当我尝试创建通过Web服务使用数据库的登录系统时会发生这种情况。我需要检查登录用户名和密码表单数据库并授予登录权限。