Advertisement
Guest User

Untitled

a guest
Jul 14th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. <form action="Startvotesystem" method="post" enctype="multipart/form-data" >
  2. <div class="form-group">
  3. <label >Title</label>
  4. <input type="text" class="form-control" name="votetitle" placeholder="Enter Title of VoteSystem">
  5. </div>
  6. <div class="form-group">
  7. <label >Objective</label>
  8. <input type="text" class="form-control" name="voteobjective" placeholder="Enter objective of VoteSystem">
  9. </div>
  10. <%
  11. PrintWriter pw = response.getWriter();
  12. Connection con = DriverManager.getConnection("jdbc:db2://localhost:50000/PROJECT","sai kiran goud","saikiran123");
  13. PreparedStatement ps1 =con.prepareStatement("select name,email from userDB");
  14. ResultSet rs=ps1.executeQuery();
  15. int i=0;
  16. %>
  17. <div class="form-group">
  18. <label >Users</label>
  19.  
  20. <%
  21. while(rs.next())
  22. {
  23. if(rs.getString("email").equals(userId))
  24. continue;
  25. i++;
  26. %>
  27. <label class="checkbox">
  28. <input type="checkbox" name="multisel" value="<%=rs.getString("email")%>"> <%=rs.getString(1) %>
  29. </label>
  30.  
  31.  
  32. <%
  33. }
  34. %>
  35.  
  36. <script type="text/javascript">
  37. function checkfile(sender) {
  38. var validExts = new Array(".csv");
  39. var fileExt = sender.value;
  40. fileExt = fileExt.substring(fileExt.lastIndexOf('.'));
  41. if (validExts.indexOf(fileExt) < 0) {
  42. alert("Invalid file selected, valid files are of " +
  43. validExts.toString() + " types.");
  44. return false;
  45. }
  46. else return true;
  47. }
  48. </script>
  49. <div class="form-group">
  50. <label for="exampleInputFile">File input</label>
  51. <input type="file" name="csvfile" accept=".csv" onchange="checkfile(this);">
  52. <p class="help-block">Upload CSV comma seperated.</p>
  53. </div>
  54. </div>
  55. <button type="submit" class="btn btn-default">Submit</button>
  56. </form>
  57.  
  58. PreparedStatement check=con.prepareStatement("select * from voteDB");
  59. ResultSet checkrs = check.executeQuery();
  60. int count = 0;
  61.  
  62. while (checkrs.next())
  63. {
  64. ++count;
  65. // Get data from the current row and use it
  66.  
  67. }
  68. count=count+100;
  69. System.out.println("not found checkrs"+count);
  70. PreparedStatement ps=con.prepareStatement("insert into voteDB values(?,?,?,?)");
  71. ps.setInt(1,count);
  72. ps.setString(2,title);
  73. ps.setString(3,obj);
  74. int i=ps.executeUpdate();
  75. if(i>0)
  76. {
  77. Statement statement = con.createStatement();
  78.  
  79. String cmd ="create table userslist (voteId int,users varchar(30) not null, foreign key (voteID) references PROJECT.voteDB (voteID) on delete restrict)";
  80. statement.executeUpdate(cmd);
  81. cmd ="create table objectslist (voteId int,items varchar(30) not null, foreign key (voteID) references PROJECT.voteDB (voteID) on delete restrict)";
  82. statement.executeUpdate(cmd);}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement