Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring mvc 如何使用SpringMVC检查电子邮件是否已在MYSQL数据库中注册?_Spring Mvc - Fatal编程技术网

Spring mvc 如何使用SpringMVC检查电子邮件是否已在MYSQL数据库中注册?

Spring mvc 如何使用SpringMVC检查电子邮件是否已在MYSQL数据库中注册?,spring-mvc,Spring Mvc,如何使用SpringMVC检查电子邮件是否已在MYSQL数据库中注册 我也尝试 public boolean exists(String email) throws SQLException { Connection conn= DriverManager.getConnection("jdbc:mysql://localhost:3306/Spring3", "root", "root"); Statement st=conn.prepareStatement("select

如何使用SpringMVC检查电子邮件是否已在MYSQL数据库中注册

我也尝试

public boolean exists(String email) throws SQLException {
    Connection conn= DriverManager.getConnection("jdbc:mysql://localhost:3306/Spring3", "root", "root");

    Statement st=conn.prepareStatement("select * from Registration");
    ResultSet rs=st.executeQuery("select * from Registration");
    while (rs.next()) {
        if (email.equals(rs.getString("email"))) {
            System.out.println("Email already registerd!!");
            return true;
        }
    }
    return false;

}
可能重复的
...
    PreparedStatement st=conn.prepareStatement("select * from Registration where email='"+email+"'");
    ResultSet rs=st.executeQuery();
    if (rs.next()) {
        System.out.println("Exists!");
    }
    else{
        System.out.println("Does Not Exist!");
    }
...