Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@page import="java.sql.*"%>
- <html>
- <body>
- <%
- String[] id = request.getParameterValues("assignchkbox");
- String armID = request.getParameter("ArmID");
- String armnumber = request.getParameter("Armnumber");
- int count=0;
- Connection conn = null;
- try {
- Class.forName("com.mysql.jdbc.Driver");
- // Step 2: Define Connection URL
- String connURL = "jdbc:mysql://wordpresstest.caqsulr2hhv7.ap-southeast-1.rds.amazonaws.com/medicloud?user=chenyuli&password=root1234";
- // Step 3: Establish connection to URL
- conn = DriverManager.getConnection(connURL);
- if (id != null)
- {
- for( int i=0; i<id.length; i++){
- String sqlStr = "Insert into assign(ArmID,Armnumber) Value(?,?)";
- PreparedStatement pstmt = conn.prepareStatement(sqlStr);
- pstmt.setInt(1, Integer.parseInt(id[i]));
- pstmt.setString(2,armnumber);
- //pstmt.setInt(1, Integer.parseInt(ids[i]));
- int rec=pstmt.executeUpdate();
- if (rec==1)
- count++;
- }
- }
- %>
- <%
- String[] id1 = request.getParameterValues("assignchkbox1");
- String legID = request.getParameter("LegID");
- String legnumber = request.getParameter("Legnumber");
- int count1=0;
- Connection conn1 = null;
- try {
- Class.forName("com.mysql.jdbc.Driver");
- // Step 2: Define Connection URL
- String conn1URL = "jdbc:mysql://wordpresstest.caqsulr2hhv7.ap-southeast-1.rds.amazonaws.com/medicloud?user=chenyuli&password=root1234";
- // Step 3: Establish connection to URL
- conn1 = DriverManager.getConnection(conn1URL);
- if (id1 != null)
- {
- for( int i=0; i<id1.length; i++){
- String sqlStr = "Insert into assign(LegID,Legnumber) Value(?,?)";
- PreparedStatement pstmt = conn.prepareStatement(sqlStr);
- pstmt.setInt(1, Integer.parseInt(id1[i]));
- pstmt.setString(2,legnumber);
- //pstmt.setInt(1, Integer.parseInt(ids[i]));
- int rec=pstmt.executeUpdate();
- if (rec==1)
- count1++;
- }
- }
- %>
- <%
- String[] id2 = request.getParameterValues("assignchkbox2");
- String userId = request.getParameter("UserID");
- int count2=0;
- Connection conn2 = null;
- try {
- Class.forName("com.mysql.jdbc.Driver");
- // Step 2: Define Connection URL
- String conn2URL = "jdbc:mysql://wordpresstest.caqsulr2hhv7.ap-southeast-1.rds.amazonaws.com/medicloud?user=chenyuli&password=root1234";
- // Step 3: Establish connection to URL
- conn2 = DriverManager.getConnection(conn2URL);
- if (id2 != null)
- {
- for( int i=0; i<id2.length; i++){
- String sqlStr = "Insert into assign(id, userID) Value(?,?)";
- PreparedStatement pstmt = conn.prepareStatement(sqlStr);
- pstmt.setInt(1, Integer.parseInt(id2[i]));
- pstmt.setString(2, userId);
- //pstmt.setInt(1, Integer.parseInt(ids[i]));
- int rec=pstmt.executeUpdate();
- if(rec==1)
- count2++;
- }
- }
- %>
- <form action="assign.jsp" method="post">
- <label><%=count%> arm record(s) assigned!!</label>
- <td style width="50%">
- </form>
- <form action="assign.jsp" method="post">
- <label><%=count1%> leg record(s) assigned!!</label>
- <td style width="50%">
- </form>
- <form action="assign.jsp" method="post">
- <label><%=count2%> patients assigned!!</label>
- <p><input type="submit" value="Return" name="ReturnBtn" /></p>
- </form>
- <% //It says to add "}" and add "Finally"
- }
- finally{
- conn.close();
- conn1.close();
- conn2.close();
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- %>
- </body>
- </html>
Add Comment
Please, Sign In to add comment