我正在创建一个程序,该程序可以将用户创建并存储到数据库中
我真的没有尝试过任何事情,因为我真的不知道如何解决这个问题
String input = "";
System.out.print("Please enter in Username: ");
cuser = keyboard.nextLine();
System.out.print("Please Enter in a Password: ");
String cpassword = keyboard.nextLine();
rs = stmt.executeQuery("SELECT * FROM user1");
System.out.println("Selected from the table");
while(rs.next()) {
String user1 = rs.getString("username");
String pswd = rs.getString("password");
if(user1.trim().contentEquals(cuser) && pswd.trim().contentEquals(cpassword)) {
System.out.println("The username "+ user1.trim() +" with the password "+ pswd.trim()+ " Exists");
System.out.print("Would you like to view your profile ? Enter Yes or No: ");
input = keyboard.nextLine();
if(input.charAt(0) == 'Y'|| input.charAt(0) == 'y') {
//error occurs right here
rs = stmt.executeQuery("select * from user1 where username = username");
System.out.println("Username = " + rs.getString(1));
}// end of if statement
con.close();
System.exit(0);
}// end of while loop
我试图选择输入的用户名与表中的用户名匹配的行中的所有内容