以下试源码 请求帮助 谢谢
package zhaohua;import javax.servlet.*;
import javax.servlet.http.*;import db.*;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Date;
import java.io.*;public class chuEdit extends HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
request.setCharacterEncoding("gb2312");
response.setContentType("text/html;charset=gb2312");
PrintWriter out = response.getWriter();
String id = (String)request.getParameter("id");
String kaishishi=(String)request.getParameter("kaishishi");
String feiyongshijian = (String)request.getParameter("feiyongshijian");
String shijian=(String)request.getParameter("shijian");
String amount = (String)request.getParameter("amount");
amount = amount.replaceAll("\\.00","");
String gohoohao=(String)request.getParameter("gohoohao");
//-------------------------------------------创建shikuan连接池-----------------
Connection con = null;
try {
con = shikuan.getConnection();
} catch (Exception e1) {
e1.printStackTrace();
}
Statement stmt = null;
try {
stmt = con.createStatement();
} catch (SQLException e2) {
e2.printStackTrace();
}
//----------------------------------------------------------------------------
try{
//===============================开始=======================================
ResultSet rst = stmt.executeQuery("select yh_name,yh_bank from c_user " +
"where yh_bank <> '招商银行' and yh_id='"+ id +"'");
if(rst.next()) {
String yhbank=rst.getString("yh_bank");
String yh_name=rst.getString("yh_name");
int ji1 =stmt.executeUpdate("update c_user set yh_bank = 'jiao' where yh_id='"+ id +"'");
String yhxinbeizhughao = "编辑内容:将" + yhbank + "改为jiao";
Date yhxintimetemp =new Date();
String yhxintime = new SimpleDateFormat("yyyy-MM-dd").format(yhxintimetemp);
int ji2 = stmt.executeUpdate("INSERT INTO c_user_log(yh_id,yh_name,yh_beizhu,log_time,yh_man,yh_beizhu1,pc_time) VALUES ('"+ id +"','" + yh_name + "','" + yhxinbeizhughao +"','"+ yhxintime +"','System','用户通过jiao缴费','" + yhxintime + "')");
out.println("修改用户表状态:"+ji1+"<br>");
out.println("插入修改纪录"+ji2+"<br>");
}else{
//throw new Exception("不用jiao!"); out.println("<不用改jiao>");
}
rst.close();
int ji3 = stmt.executeUpdate("update c_fee set fee_type = '1' " +
"where yh_id = '"+ id + "' and" +
" fee_type = 'end' and" +
" convert(datetime,fee_end,121)" +
" = '"+ kaishishi +"'");
//int mothcha = kaishishi feiyongshijian;
String a=kaishishi;
String b=feiyongshijian;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Calendar a2 = Calendar.getInstance();
Calendar b2 = Calendar.getInstance();
a2.setTime(format.parse(a));
b2.setTime(format.parse(b));
int mothcha = (b2.get(Calendar.YEAR) - a2.get(Calendar.YEAR)) * 12
+ (b2.get(Calendar.MONTH) - a2.get(Calendar.MONTH));
int ji4 = stmt.executeUpdate("insert into c_fee(yh_id,fee_date,fee_end,fee_date_1,fee_fee,fee_beizhu,yh_man,fee_xu,fee_type,fee_hua,payflag,fee_month,fee_az,fee_cm) values('" + id + "','" + kaishishi + "','" + feiyongshijian + "','" + shijian + "','" + amount + "','jiao','system','1','end','已划','成功','" + mothcha + "','0','0')");
int ji5 = stmt.executeUpdate("update c_user set deadline = '" + feiyongshijian + "' where convert(datetime,deadline,121) = '" + kaishishi + "' and yh_id='" + id + "'");
con.close();
stmt.close();
//==============================结束========================================
//======================执行=====================================
//
}
catch (Exception e) {
e.printStackTrace();
}
Connection conzhao = null;
try {
conzhao = DatabaseConn.getConnection();
} catch (Exception ezhao1) {
ezhao1.printStackTrace();
}
Statement stmtzhao = null;
try {
stmtzhao = conzhao.createStatement();
} catch (SQLException ezhao2) {
ezhao2.printStackTrace();
}
try{
int cmzhao = stmtzhao.executeUpdate("update net_zhaofan set queren = '1' WHERE gohoo_liuhao = ( select b.gohoo_liuhao gohoohao FROM net_feiyong a,net_zhaofan b,basehttp c WHERE a.p_id = b.gohoo_liuhao and a.liushui = b.BillNo and c.col001 = b.Datefan and b.billno = c.col004 and b.queren = '0' and c.col005 = '0' and a.p_sum + '.00' = b.Amount and c.col003 = b.Amount and b.gohoo_liuhao = '"+ gohoohao +"')");
stmtzhao.close();
conzhao.close();
out.println("修改状态:"+cmzhao+"<br>");
}
catch(Exception ezhao)
{
ezhao.printStackTrace();
}
//----------------------------------------------------------------------------
out.println(""+id+"<br>");
out.println(""+kaishishi+"<br>");
out.println(""+feiyongshijian+"<br>");
out.println(""+shijian+"<br>");
out.println(""+amount+"<br>");
out.println(""+gohoohao+"<br>");
out.println(""+con+"<br>");
//------------------------------------------------------------------------------------------
}
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
doGet(request,response);
}
}
package zhaohua;import javax.servlet.*;
import javax.servlet.http.*;import db.*;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Date;
import java.io.*;public class chuEdit extends HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
request.setCharacterEncoding("gb2312");
response.setContentType("text/html;charset=gb2312");
PrintWriter out = response.getWriter();
String id = (String)request.getParameter("id");
String kaishishi=(String)request.getParameter("kaishishi");
String feiyongshijian = (String)request.getParameter("feiyongshijian");
String shijian=(String)request.getParameter("shijian");
String amount = (String)request.getParameter("amount");
amount = amount.replaceAll("\\.00","");
String gohoohao=(String)request.getParameter("gohoohao");
//-------------------------------------------创建shikuan连接池-----------------
Connection con = null;
try {
con = shikuan.getConnection();
} catch (Exception e1) {
e1.printStackTrace();
}
Statement stmt = null;
try {
stmt = con.createStatement();
} catch (SQLException e2) {
e2.printStackTrace();
}
//----------------------------------------------------------------------------
try{
//===============================开始=======================================
ResultSet rst = stmt.executeQuery("select yh_name,yh_bank from c_user " +
"where yh_bank <> '招商银行' and yh_id='"+ id +"'");
if(rst.next()) {
String yhbank=rst.getString("yh_bank");
String yh_name=rst.getString("yh_name");
int ji1 =stmt.executeUpdate("update c_user set yh_bank = 'jiao' where yh_id='"+ id +"'");
String yhxinbeizhughao = "编辑内容:将" + yhbank + "改为jiao";
Date yhxintimetemp =new Date();
String yhxintime = new SimpleDateFormat("yyyy-MM-dd").format(yhxintimetemp);
int ji2 = stmt.executeUpdate("INSERT INTO c_user_log(yh_id,yh_name,yh_beizhu,log_time,yh_man,yh_beizhu1,pc_time) VALUES ('"+ id +"','" + yh_name + "','" + yhxinbeizhughao +"','"+ yhxintime +"','System','用户通过jiao缴费','" + yhxintime + "')");
out.println("修改用户表状态:"+ji1+"<br>");
out.println("插入修改纪录"+ji2+"<br>");
}else{
//throw new Exception("不用jiao!"); out.println("<不用改jiao>");
}
rst.close();
int ji3 = stmt.executeUpdate("update c_fee set fee_type = '1' " +
"where yh_id = '"+ id + "' and" +
" fee_type = 'end' and" +
" convert(datetime,fee_end,121)" +
" = '"+ kaishishi +"'");
//int mothcha = kaishishi feiyongshijian;
String a=kaishishi;
String b=feiyongshijian;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Calendar a2 = Calendar.getInstance();
Calendar b2 = Calendar.getInstance();
a2.setTime(format.parse(a));
b2.setTime(format.parse(b));
int mothcha = (b2.get(Calendar.YEAR) - a2.get(Calendar.YEAR)) * 12
+ (b2.get(Calendar.MONTH) - a2.get(Calendar.MONTH));
int ji4 = stmt.executeUpdate("insert into c_fee(yh_id,fee_date,fee_end,fee_date_1,fee_fee,fee_beizhu,yh_man,fee_xu,fee_type,fee_hua,payflag,fee_month,fee_az,fee_cm) values('" + id + "','" + kaishishi + "','" + feiyongshijian + "','" + shijian + "','" + amount + "','jiao','system','1','end','已划','成功','" + mothcha + "','0','0')");
int ji5 = stmt.executeUpdate("update c_user set deadline = '" + feiyongshijian + "' where convert(datetime,deadline,121) = '" + kaishishi + "' and yh_id='" + id + "'");
con.close();
stmt.close();
//==============================结束========================================
//======================执行=====================================
//
}
catch (Exception e) {
e.printStackTrace();
}
Connection conzhao = null;
try {
conzhao = DatabaseConn.getConnection();
} catch (Exception ezhao1) {
ezhao1.printStackTrace();
}
Statement stmtzhao = null;
try {
stmtzhao = conzhao.createStatement();
} catch (SQLException ezhao2) {
ezhao2.printStackTrace();
}
try{
int cmzhao = stmtzhao.executeUpdate("update net_zhaofan set queren = '1' WHERE gohoo_liuhao = ( select b.gohoo_liuhao gohoohao FROM net_feiyong a,net_zhaofan b,basehttp c WHERE a.p_id = b.gohoo_liuhao and a.liushui = b.BillNo and c.col001 = b.Datefan and b.billno = c.col004 and b.queren = '0' and c.col005 = '0' and a.p_sum + '.00' = b.Amount and c.col003 = b.Amount and b.gohoo_liuhao = '"+ gohoohao +"')");
stmtzhao.close();
conzhao.close();
out.println("修改状态:"+cmzhao+"<br>");
}
catch(Exception ezhao)
{
ezhao.printStackTrace();
}
//----------------------------------------------------------------------------
out.println(""+id+"<br>");
out.println(""+kaishishi+"<br>");
out.println(""+feiyongshijian+"<br>");
out.println(""+shijian+"<br>");
out.println(""+amount+"<br>");
out.println(""+gohoohao+"<br>");
out.println(""+con+"<br>");
//------------------------------------------------------------------------------------------
}
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
doGet(request,response);
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货