Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
evoting ppt.pptx
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11. DBCONNECTION
This is the class which contains the code to load the driver and open
the connection with the database.
public class DBConnection {
private static Connection conn=null;
static{
try{
Class.forName("oracle.jdbc.OracleDriver");
conn=DriverManager.getConnection("jdbc:oracle:thin:@//DESKTOP-CHE429J:1521/XE","advjavabatch",
"mystudents");
System.out.println("Connection opend successfully");
}
STEPS TO BE DONE IN DBConnection CLASS
12. catch(ClassNotFoundException e){
JOptionPane.showMessageDialog(null, "Cannot load the
driver","ERROR",JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
}
catch(SQLException e){
JOptionPane.showMessageDialog(null, "Problem in Db","ERROR",JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
}
}
public static Connection getConnection(){
return conn;
}
public static void closeConnection(){
try{
if(conn!=null)
conn.close();
}
13. HOW TO REGISTER USER
To do this we need to create a method in RegistrationDAO called registerUser()
which accept a UserDetails object as argument and INSERT a new record in the
USER_DETAILS TABLE .Finally it will return true or false depending on whether
record is inserted or not.
THE RegistrationControllerServlet CLASS
The RegistrationControllerServlet will do the following:
a. Retrieve the request parameters
b. Call the RegistrationDAO.searchUser( ) method passing it the userid as argument.
c. If the method searchUser( ) returns false, then initialize a UserDetails object with the
user details and call the method registerUser( ) sending the UserDetails object as
argument
14. public class RegistrationDao {
private static PreparedStatement ps,ps1;
static
{
try {
ps=DBConnection.getConnection().prepareStatement("select * from user_details where
adhar_no=?");
ps1=DBConnection.getConnection().prepareStatement("insert into user_details
values(?,?,?,?,?,?,?,?)");
} catch (SQLException ex) {
ex.printStackTrace();
}
}
public static boolean searchUser(String userid)throws SQLException
{
ps.setString(1, userid);
return ps.executeQuery().next();
}
17. HOW TO SEARCH USER
To do this we need to create a method in RegistrationDAO called searchUser() which will
accept a adhar_no as argument , search the USER_DETAILS TABLE for the given adhar_no
and return true or false depending on whether record is found or not.
Following is the code:
public static boolean searchUser(String userid)throws SQLException
{
ps.setString(1, userid);
return ps.executeQuery().next();
}
19. HOW TO VERIFY USERID/PASSWORD
To do this we need to create a method in UserDAO called validateUser() which will accept a UserDTO
object as argument , search the USER_DETAILS TABLE for the given UserId and Password and return
Usertype or null depending on whether record is found or not.
Following is the code:
public static String validateUser(UserDto user) throws SQLException {
ps2.setString(1,user.getUserid());
ps2.setString(2,user.getPassword());
ResultSet rs=ps2.executeQuery();
if(rs.next())
return rs.getString(8);
else
return null;
}
20. • When user click on Update Candidate div then it should generate a dynamic drop
down and set all the candidate id on that drop down
• And when user choose a candidate id then it should display the details of that
candidate which’s userid user chooses from drop down.
• When it display then on thing also remember that user only modify party, city and
image of candidate. It means we should disable all the input control Except city,
party and image.
THE UPDATE CANDIDATE MODULE
DELETE CANDIDATE MODULE
• When user click on delete candidate div then it should display a dynamic dropdown
which contains id of the all the candidates.
• And when user select any id from the dropdown then it should display the details of
candidate and also show a remove button below .
• When user click on remove button then it should remove the candidate from the
database and also dropdown data.