Guest User

Untitled

a guest
Jul 4th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.92 KB | None | 0 0
  1. <%@page import="java.sql.*"%>
  2.  
  3. <html>
  4. <body>
  5. <%
  6.  
  7. String[] id = request.getParameterValues("assignchkbox");
  8. String armID = request.getParameter("ArmID");
  9. String armnumber = request.getParameter("Armnumber");
  10. int count=0;
  11. Connection conn = null;
  12. try {
  13. Class.forName("com.mysql.jdbc.Driver");
  14. // Step 2: Define Connection URL
  15. String connURL = "jdbc:mysql://wordpresstest.caqsulr2hhv7.ap-southeast-1.rds.amazonaws.com/medicloud?user=chenyuli&password=root1234";
  16. // Step 3: Establish connection to URL
  17. conn = DriverManager.getConnection(connURL);
  18.  
  19. if (id != null)
  20. {
  21. for( int i=0; i<id.length; i++){
  22.  
  23. String sqlStr = "Insert into assign(ArmID,Armnumber) Value(?,?)";
  24. PreparedStatement pstmt = conn.prepareStatement(sqlStr);
  25. pstmt.setInt(1, Integer.parseInt(id[i]));
  26. pstmt.setString(2,armnumber);
  27. //pstmt.setInt(1, Integer.parseInt(ids[i]));
  28. int rec=pstmt.executeUpdate();
  29. if (rec==1)
  30. count++;
  31.  
  32. }
  33. }
  34.  
  35.  
  36. %>
  37.  
  38.  
  39.  
  40. <%
  41. String[] id1 = request.getParameterValues("assignchkbox1");
  42. String legID = request.getParameter("LegID");
  43. String legnumber = request.getParameter("Legnumber");
  44. int count1=0;
  45. Connection conn1 = null;
  46. try {
  47. Class.forName("com.mysql.jdbc.Driver");
  48. // Step 2: Define Connection URL
  49. String conn1URL = "jdbc:mysql://wordpresstest.caqsulr2hhv7.ap-southeast-1.rds.amazonaws.com/medicloud?user=chenyuli&password=root1234";
  50. // Step 3: Establish connection to URL
  51. conn1 = DriverManager.getConnection(conn1URL);
  52.  
  53. if (id1 != null)
  54. {
  55. for( int i=0; i<id1.length; i++){
  56.  
  57. String sqlStr = "Insert into assign(LegID,Legnumber) Value(?,?)";
  58. PreparedStatement pstmt = conn.prepareStatement(sqlStr);
  59. pstmt.setInt(1, Integer.parseInt(id1[i]));
  60. pstmt.setString(2,legnumber);
  61. //pstmt.setInt(1, Integer.parseInt(ids[i]));
  62. int rec=pstmt.executeUpdate();
  63. if (rec==1)
  64. count1++;
  65. }
  66.  
  67. }
  68.  
  69.  
  70. %>
  71.  
  72. <%
  73. String[] id2 = request.getParameterValues("assignchkbox2");
  74. String userId = request.getParameter("UserID");
  75. int count2=0;
  76. Connection conn2 = null;
  77. try {
  78. Class.forName("com.mysql.jdbc.Driver");
  79. // Step 2: Define Connection URL
  80. String conn2URL = "jdbc:mysql://wordpresstest.caqsulr2hhv7.ap-southeast-1.rds.amazonaws.com/medicloud?user=chenyuli&password=root1234";
  81. // Step 3: Establish connection to URL
  82. conn2 = DriverManager.getConnection(conn2URL);
  83.  
  84. if (id2 != null)
  85. {
  86. for( int i=0; i<id2.length; i++){
  87.  
  88. String sqlStr = "Insert into assign(id, userID) Value(?,?)";
  89. PreparedStatement pstmt = conn.prepareStatement(sqlStr);
  90. pstmt.setInt(1, Integer.parseInt(id2[i]));
  91. pstmt.setString(2, userId);
  92. //pstmt.setInt(1, Integer.parseInt(ids[i]));
  93. int rec=pstmt.executeUpdate();
  94. if(rec==1)
  95. count2++;
  96. }
  97.  
  98. }
  99. %>
  100.  
  101. <form action="assign.jsp" method="post">
  102. <label><%=count%> arm record(s) assigned!!</label>
  103. <td style width="50%">
  104.  
  105. </form>
  106.  
  107. <form action="assign.jsp" method="post">
  108. <label><%=count1%> leg record(s) assigned!!</label>
  109. <td style width="50%">
  110. </form>
  111.  
  112. <form action="assign.jsp" method="post">
  113. <label><%=count2%> patients assigned!!</label>
  114. <p><input type="submit" value="Return" name="ReturnBtn" /></p>
  115. </form>
  116. <% //It says to add "}" and add "Finally"
  117. }
  118. finally{
  119. conn.close();
  120. conn1.close();
  121. conn2.close();
  122.  
  123. }
  124. }
  125. catch (Exception e) {
  126. e.printStackTrace();
  127. }
  128.  
  129.  
  130. %>
  131. </body>
  132. </html>
Add Comment
Please, Sign In to add comment