An online voting system based on Access database.
Beforevote.jsp
<% @ Page ContentType = "Text / HTML; Charset = UTF-8"%> <% @ Page Import = "Java.sql. *"%>
<% // jdbc connection database has two ways: JDBC-ODBC bridge mode and dedicated JDBC connection method for a particular database. // This case uses JDBC-ODBC bridge mode. // ODBC data source name: votedsn // table Candidates ---- Store candidate's name: Name and ticket: count // Table Voters ---- Store the voter's IP: voterip //, Fill in the candidate's name and initial votes into the Candidates table. %>
<% stringBuffer CandidatesList = new stringbuffer (); connection con; // 加 加 c j; ("Sun.jdbc.odbc.jdbcodbcdriver"); // /Class.forname ("Oracle.jdbc.driver.Oracledriver");} catch (ClassNotFoundException E) {E.PrintStackTrace ();} // Connect the database and read the contents of the Candidates table Try {Con = DriverManager.getConnection JDBC: ODBC: Vote "," "" "); // con = DriverManager.getConnection (" JDBC: Oracle: Thin: @ 192.168.0.3: 1521: kWDB "," Okjohn "," Password "); // Dedicated JDBC mode SQL = con.createstatement (); rs = sql.executeQuery ("Select * from Candidates"); CandidatesList.Append ("