<%@ page contentType="text/html; charset=UTF-8" language="java" import="java.sql.*" errorPage="" %> <%@ page import="java.sql.*,com.csc.library.database.ConnectDB,com.csc.library.utilities.UProfile"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <% UProfile up=(UProfile)session.getAttribute("userprofile"); if(up!=null){ %> <form name="cscform" method="post"> <p align="center"><strong>Update Data</strong></p> <table align="center"> <tr> <td width="104">DataBase :</td> <td width="317"><input type="text" size="15" name="db" value='<%=request.getParameter("db")%>'></td> </tr> <tr> <td height="130">SQL Command :</td> <td><textarea rows="8" cols="50" name="cmd" ></textarea></td> </tr> <tr> <td align="center" colspan="2"><input type="submit" name="submit"> <input type="reset" name="reset"></td> </tr> <% if(request.getParameter("submit") !=null) { String db = request.getParameter("db"); String sql = request.getParameter("cmd"); ConnectDB cdb =null; Connection conn = null; Statement st =null; out.println(" Old SQL Command :: "+request.getParameter("cmd")+"<BR><BR>"); try{ cdb = new ConnectDB(); conn = cdb.getConnection(db); st = conn.createStatement(); if(sql.indexOf(";")>-1){ String[] sql2 = sql.split(";"); for(int c=0;c<sql2.length;c++){ sql = sql2[c]; st.executeUpdate(sql); conn.commit(); } }else{ st.executeUpdate(sql); conn.commit(); } }catch(Exception e){ out.println(" Error :: "+e); }finally{ if(st!=null){ st.close(); } if(conn != null){ conn.commit(); conn.close(); } } } %> </table> </form> <%}%> </body> </html>