•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 423,883 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,246 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 2336 | Replies: 0
![]() |
•
•
Join Date: Sep 2005
Location: london
Posts: 16
Reputation:
Rep Power: 4
Solved Threads: 1
Hi everyone, i am building a voting system and i am trying to count the number of votes for each candidate to be stored in a candidates table in the field voteresult, i have stored the results in a bean, and written the sql query statement in a jsp page. When i try the code the voteresult field was not updating or incrementing. Please i need a some help, any help or suggestion would be appreciated. Thanks
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection c = DriverManager.getConnection("jdbc:mysql:///Voting");
Statement st = c.createStatement();
st.executeUpdate("update voters set vote1 = '" + Vote.getVote1()
+ "', vote2 = '" + Vote.getVote2() + "', vote3 = '" + Vote.getVote3()
+ "', vote4 = '" + Vote.getVote4() + "', vote5 = '" + Vote.getVote5()
+ "', vote6 = '" + Vote.getVote6()
+ "', timestamp = '" + Vote.getTimeStamp() + "', voted = '1' where username = '" + Vote.getUserName() + "'");
st = c.createStatement();
st.executeUpdate("update candidates set voteresult = voteresult + 1 where name = '" + Vote.getVote1().trim() + "'");
st = c.createStatement();
st.executeUpdate("update candidates set voteresult = voteresult + 1 where name = '" + Vote.getVote2() + "'");
st = c.createStatement();
st.executeUpdate("update candidates set voteresult = voteresult + 1 where name = '" + Vote.getVote3() + "'");
st = c.createStatement();
st.executeUpdate("update candidates set voteresult = voteresult + 1 where name = '" + Vote.getVote4() + "'");
st = c.createStatement();
st.executeUpdate("update candidates set voteresult = voteresult + 1 where name = '" + Vote.getVote5() + "'");
st = c.createStatement();
st.executeUpdate("update candidates set voteresult = voteresult + 1 where name = '" + Vote.getVote6() + "'");
st.close();
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection c = DriverManager.getConnection("jdbc:mysql:///Voting");
Statement st = c.createStatement();
st.executeUpdate("update voters set vote1 = '" + Vote.getVote1()
+ "', vote2 = '" + Vote.getVote2() + "', vote3 = '" + Vote.getVote3()
+ "', vote4 = '" + Vote.getVote4() + "', vote5 = '" + Vote.getVote5()
+ "', vote6 = '" + Vote.getVote6()
+ "', timestamp = '" + Vote.getTimeStamp() + "', voted = '1' where username = '" + Vote.getUserName() + "'");
st = c.createStatement();
st.executeUpdate("update candidates set voteresult = voteresult + 1 where name = '" + Vote.getVote1().trim() + "'");
st = c.createStatement();
st.executeUpdate("update candidates set voteresult = voteresult + 1 where name = '" + Vote.getVote2() + "'");
st = c.createStatement();
st.executeUpdate("update candidates set voteresult = voteresult + 1 where name = '" + Vote.getVote3() + "'");
st = c.createStatement();
st.executeUpdate("update candidates set voteresult = voteresult + 1 where name = '" + Vote.getVote4() + "'");
st = c.createStatement();
st.executeUpdate("update candidates set voteresult = voteresult + 1 where name = '" + Vote.getVote5() + "'");
st = c.createStatement();
st.executeUpdate("update candidates set voteresult = voteresult + 1 where name = '" + Vote.getVote6() + "'");
st.close();
![]() |
•
•
•
•
•
•
•
•
DaniWeb JSP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Collapsible table sorting problem (JavaScript / DHTML / AJAX)
- Firefox problem - can't install update and Thunderbird -"fights" with Netscape! (Windows NT / 2000 / XP / 2003)
- ComboBox UpDate Problem (VB.NET)
- Windows Update Problem (Windows NT / 2000 / XP / 2003)
- MySql multiple table query problem.... (MySQL)
- Database not being populated.... (Java)
- WMI Update Problem (Windows NT / 2000 / XP / 2003)
Other Threads in the JSP Forum
- Previous Thread: java bean
- Next Thread: project in j2ee


Linear Mode