SlideShare a Scribd company logo
1 of 26
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
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();
}
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
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();
}
public static boolean registerUser(UserDetails user) throws SQLException {
ps1.setString(1, user.getUserid());
ps1.setString(2,user.getPassword());
ps1.setString(3,user.getUsername());
ps1.setString(4, user.getAddress());
ps1.setString(5, user.getCity());
ps1.setString(6,user.getEmail());
ps1.setLong(7, user.getMobile());
ps1.setString(8, "Voter");
return ps1.executeUpdate()==1;
}
}
Registration Page All field are mandatory
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();
}
Login page Wrong Password
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;
}
• 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.
CRUD OPERATION
CONSTRAINT APPLIED
 Alter table user_details add constraint ud_an_pk primary key(adhar_no);
 Alter table candidate add constraint cd_cid_pk primary key(candidate_id);
 Alter table candidate add constraint cd_uid_fk foreign key(user_id) references
user_details(adhar_no);
 Alter table voting add constraint vt_cid_fk foreign key(candidate_id) references
candidate(candidate_id);
 Alter table voting add constraint vt_vid_pk primary key(voter_id);
 Alter table voting add constraint vt_vid_fk foreign key(voter_id) references
DATABASE
Candidate table structure
User table structure
Voting table structure Dummy Data
Inner join opetaion
evoting ppt.pptx

More Related Content

Similar to evoting ppt.pptx

Similar to evoting ppt.pptx (20)

Data Access with JDBC
Data Access with JDBCData Access with JDBC
Data Access with JDBC
 
spring-tutorial
spring-tutorialspring-tutorial
spring-tutorial
 
Jdbc tutorial
Jdbc tutorialJdbc tutorial
Jdbc tutorial
 
jdbc
jdbcjdbc
jdbc
 
Jdbc
JdbcJdbc
Jdbc
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenches
 
Vpd Virtual Private Database By Saurabh
Vpd   Virtual Private Database By SaurabhVpd   Virtual Private Database By Saurabh
Vpd Virtual Private Database By Saurabh
 
Lecture17
Lecture17Lecture17
Lecture17
 
Cursor Demo App
Cursor Demo AppCursor Demo App
Cursor Demo App
 
Zend Framework 2 - Basic Components
Zend Framework 2  - Basic ComponentsZend Framework 2  - Basic Components
Zend Framework 2 - Basic Components
 
Jdbc
JdbcJdbc
Jdbc
 
JPA 2.0
JPA 2.0JPA 2.0
JPA 2.0
 
Jdbc example program with access and MySql
Jdbc example program with access and MySqlJdbc example program with access and MySql
Jdbc example program with access and MySql
 
Jdbc[1]
Jdbc[1]Jdbc[1]
Jdbc[1]
 
JDBC programming
JDBC programmingJDBC programming
JDBC programming
 
Hidden Docs in Angular
Hidden Docs in AngularHidden Docs in Angular
Hidden Docs in Angular
 
Teste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrityTeste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrity
 
Jdbc day-1
Jdbc day-1Jdbc day-1
Jdbc day-1
 
JDBC Connecticity.ppt
JDBC Connecticity.pptJDBC Connecticity.ppt
JDBC Connecticity.ppt
 
JDBC
JDBCJDBC
JDBC
 

Recently uploaded

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)Samir Dash
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAnitaRaj43
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 

Recently uploaded (20)

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
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(); }
  • 15. public static boolean registerUser(UserDetails user) throws SQLException { ps1.setString(1, user.getUserid()); ps1.setString(2,user.getPassword()); ps1.setString(3,user.getUsername()); ps1.setString(4, user.getAddress()); ps1.setString(5, user.getCity()); ps1.setString(6,user.getEmail()); ps1.setLong(7, user.getMobile()); ps1.setString(8, "Voter"); return ps1.executeUpdate()==1; } }
  • 16. Registration Page All field are mandatory
  • 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(); }
  • 18. Login page Wrong Password
  • 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.
  • 22. CONSTRAINT APPLIED  Alter table user_details add constraint ud_an_pk primary key(adhar_no);  Alter table candidate add constraint cd_cid_pk primary key(candidate_id);  Alter table candidate add constraint cd_uid_fk foreign key(user_id) references user_details(adhar_no);  Alter table voting add constraint vt_cid_fk foreign key(candidate_id) references candidate(candidate_id);  Alter table voting add constraint vt_vid_pk primary key(voter_id);  Alter table voting add constraint vt_vid_fk foreign key(voter_id) references