RSS Forums RSS
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 2523 | Replies: 0
Join Date: Sep 2005
Location: london
Posts: 16
Reputation: bondito is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
bondito bondito is offline Offline
Newbie Poster

Table Update Problem

  #1  
Apr 23rd, 2006
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();
AddThis Social Bookmark Button
Reply With Quote  

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:57 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC