Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="Startvotesystem" method="post" enctype="multipart/form-data" >
- <div class="form-group">
- <label >Title</label>
- <input type="text" class="form-control" name="votetitle" placeholder="Enter Title of VoteSystem">
- </div>
- <div class="form-group">
- <label >Objective</label>
- <input type="text" class="form-control" name="voteobjective" placeholder="Enter objective of VoteSystem">
- </div>
- <%
- PrintWriter pw = response.getWriter();
- Connection con = DriverManager.getConnection("jdbc:db2://localhost:50000/PROJECT","sai kiran goud","saikiran123");
- PreparedStatement ps1 =con.prepareStatement("select name,email from userDB");
- ResultSet rs=ps1.executeQuery();
- int i=0;
- %>
- <div class="form-group">
- <label >Users</label>
- <%
- while(rs.next())
- {
- if(rs.getString("email").equals(userId))
- continue;
- i++;
- %>
- <label class="checkbox">
- <input type="checkbox" name="multisel" value="<%=rs.getString("email")%>"> <%=rs.getString(1) %>
- </label>
- <%
- }
- %>
- <script type="text/javascript">
- function checkfile(sender) {
- var validExts = new Array(".csv");
- var fileExt = sender.value;
- fileExt = fileExt.substring(fileExt.lastIndexOf('.'));
- if (validExts.indexOf(fileExt) < 0) {
- alert("Invalid file selected, valid files are of " +
- validExts.toString() + " types.");
- return false;
- }
- else return true;
- }
- </script>
- <div class="form-group">
- <label for="exampleInputFile">File input</label>
- <input type="file" name="csvfile" accept=".csv" onchange="checkfile(this);">
- <p class="help-block">Upload CSV comma seperated.</p>
- </div>
- </div>
- <button type="submit" class="btn btn-default">Submit</button>
- </form>
- PreparedStatement check=con.prepareStatement("select * from voteDB");
- ResultSet checkrs = check.executeQuery();
- int count = 0;
- while (checkrs.next())
- {
- ++count;
- // Get data from the current row and use it
- }
- count=count+100;
- System.out.println("not found checkrs"+count);
- PreparedStatement ps=con.prepareStatement("insert into voteDB values(?,?,?,?)");
- ps.setInt(1,count);
- ps.setString(2,title);
- ps.setString(3,obj);
- int i=ps.executeUpdate();
- if(i>0)
- {
- Statement statement = con.createStatement();
- String cmd ="create table userslist (voteId int,users varchar(30) not null, foreign key (voteID) references PROJECT.voteDB (voteID) on delete restrict)";
- statement.executeUpdate(cmd);
- cmd ="create table objectslist (voteId int,items varchar(30) not null, foreign key (voteID) references PROJECT.voteDB (voteID) on delete restrict)";
- statement.executeUpdate(cmd);}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement