One of the most important thing in applications is to check email id exist or not.
Email verification existence plays a major role while the application is running.
There are so many places are there where we need to check email id is there or not.
For example during forget password recovery we first check whether email id exist or not.Here is the java program to check email id already exist in database or not.
import java.sql.*;
class EmailExistenceCheck {
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
String email=sc.next();
EmailExistenceCheck.emailValidate(email);
}
public static void emailValidate(String email){
boolean status=false;
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con= DriverManager.getConnection
("jdbc:oracle:thin:@localhost:1521:xe","system","system");
PreparedStatement pstmt=con.prepareStatement(
"select * from login where email=?");
pstmt.setString(1,email);
ResultSet rs=pstmt.executeQuery();
status=rs.next();
if(status){
System.out.println("email id already exist");
}
else{
System.out.println("email id does not exist");
}
}catch(Exception e){System.out.println(e);}
}
}
How to check email already exist in database in java using servlet.
No comments:
Post a Comment