package com.sj.qitaservlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.sj.util.DBUtil;
public class UpdategparkinfoServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
public UpdategparkinfoServlet() {
super();
}
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/json;charset=utf-8");
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
JSONObject jobj = new JSONObject();
JSONArray jarray = new JSONArray();
String xiu_tccmz;
String xiu_zcw;
String xiu_tccdz;
String xiu_tccdh;
xiu_tccmz = request.getParameter("xtccmz");
xiu_zcw = request.getParameter("xzcw");
xiu_tccdz = request.getParameter("xtccdz");
xiu_tccdh = request.getParameter("xtccdh");
System.out.println("xtccmz" + "," + xiu_tccmz);
System.out.println("xzcw" + "," + xiu_zcw);
System.out.println("xtccdz" + "," + xiu_tccdz);
System.out.println("xtccdh" + "," + xiu_tccdh);
DBUtil con=new DBUtil();
Connection conn=con.openConnection();
Statement st;
try {
JSONObject no=new JSONObject();
try {
st = (Statement) conn.createStatement();
st.executeUpdate("UPDATE park_info SET tccmz = '"+xiu_tccmz+"',zcw= '"+xiu_zcw+"', tccdz= '"+xiu_tccdz+"', tccdh= '"+xiu_tccdh+"' WHERE tccid= ");
conn.close();
no.put("fanhui", "修改成功");
jarray.put(no);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
jobj.put("updateparkinfo", jarray);
out.print(jobj.toString());
System.out.println(jobj.toString());
} catch (JSONException e)
{
e.printStackTrace();
}
System.out.println("修改数据成功!");
out.flush();
out.close();
}
}