📄 dateeditplan.java
字号:
/*
*
*/
import java.io.*;
import java.text.*;
import java.sql.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
*
*
* @author Chen Xin Wu
*/
public class DateEditPlan extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
HtmlOut htmlOut = new HtmlOut (response);
// 得到名字和口令
String name,pass;
Person person = new Person();
person.setName (CommonMethods.GetUserName(request));
pass = CommonMethods.GetUserPass (request);
if( person.getName ()==null || (!person.checkPassword(pass)) )
{
htmlOut.setErrorID (htmlOut.USER_NEED_LOGIN,
"","用户不存在或用户密码错误"
,"Login?action=reLog");
return;
}
name= person.getName ();
int i=0 ,length=0;
length = request.getParameterValues ("col").length ;
String[] result = new String [length];
result = request.getParameterValues ("col");
for (i=0;i < length;i++)
{
//byte [] by = result[i].getBytes ("8859_1");
//result[i] = new String (by);
result[i]=CommonMethods.DealWithGBCodeOfRequest (result[i]);
}
//将用户定制的城市信息插入ps_weather表中
Connection con;
String queryString1,queryString2;
Statement stmt;
ResultSet rs;
con = CommonMethods.getDBConnection("ps_weather");
if(con==null){
htmlOut.setErrorID(htmlOut.DATABASE_CANT_CONNECT,"",
"无法连接数据库","");
return;
}
queryString1 = "delete from ps_weather where user_name='"+ name +"'" ;//erson.getName()+"'";
try
{
stmt = con.createStatement();
stmt.executeUpdate (queryString1);
for (i=0;i<length;i++)
{
queryString2 = "INSERT INTO ps_weather(User_name, QX_dz) VALUES('"+name+"'"+","+"'"+result[i]+"'"+")";
stmt.executeUpdate (queryString2);
}
//rs.close();
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("ReplaceEngine SQLException: " + ex.getMessage());
return ;
}
response.sendRedirect ("Login");
}
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
doGet(request,response);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -