I wrote a Java app in which users can login/register. This is working already. But somehow when I tried coding the logic to check if the user already exists I get an error over error.
This is my code:
public static void checkRegister(String mail) {
try {
// create a mysql database connection
Class.forName(myDriver);
Connection conn = DriverManager.getConnection(myUrl, user, passwordDB);
// the mysql insert statement
String query = "SELECT COUNT(email) mailc, email from users where users.email = \"" + mail + "\"";
// create the mysql insert preparedstatement
PreparedStatement preparedStmt = conn.prepareStatement(query);
// execute the preparedstatement
preparedStmt.execute();
conn.close();
} catch (Exception e) {
System.err.println("Got an exception!");
System.err.println(e.getMessage());
}
}
I tried using preparedStmt.getResultSet().getInt("mailc") but it doesnt work.
example mail not registered yet:
example mail already registered:
My aim is to check if mailc is > 0.

