当前位置: 技术问答>java相关
JSP中,数据更新(UPDATE)的奇怪问题!!!怪!!!!!!!!!!!1
来源: 互联网 发布时间:2015-11-06
本文导语: 程序执行UPDATE后,数据库中的相应表打不开,JSP的页面刷新具慢,只有把APACHE停掉后,才可以打开SQL2000中的表,但,UPDATE的功能没有实现!!! inc=action.compareTo(update); if (inc==0) { String id=request.getParameter("id"); out.printl...
程序执行UPDATE后,数据库中的相应表打不开,JSP的页面刷新具慢,只有把APACHE停掉后,才可以打开SQL2000中的表,但,UPDATE的功能没有实现!!!
inc=action.compareTo(update);
if (inc==0)
{
String id=request.getParameter("id");
out.println(id);
String nianj=request.getParameter("nianj");
String yuej=request.getParameter("yuej");
String rij=request.getParameter("rij");
String nianc=request.getParameter("nianc");
String yuec=request.getParameter("yuec");
String ric=request.getParameter("ric");
String shi1=nianj+"-"+yuej+"-"+rij;
out.println(shi1);
String shi2=nianc+"-"+yuec+"-"+ric;
out.println(shi2);
String stat=request.getParameter("stat");
stat=new String(stat.getBytes("ISO8859-1"),"GB2312");
out.println(stat);
shi1=new String(shi1.getBytes("ISO8859-1"),"GB2312");
shi2=new String(shi2.getBytes("ISO8859-1"),"GB2312");
String sql = "update intent_form set status='"+stat+"',rectime='"+shi1+"',lastdealtime='"+shi2+"' where id='"+id+"'";
out.println(sql);
stmt.executeUpdate(sql);
//String sql="update 表名 set 字段一=?,字段二=?";
//PreparedStatement pstmt = con.prepareStatement(sql);
//pstmt.setString(1,参数1);
//pstmt.setString(2,参数2);
//pstmt.executeUpdate();
stmt.close();
}
inc=action.compareTo(update);
if (inc==0)
{
String id=request.getParameter("id");
out.println(id);
String nianj=request.getParameter("nianj");
String yuej=request.getParameter("yuej");
String rij=request.getParameter("rij");
String nianc=request.getParameter("nianc");
String yuec=request.getParameter("yuec");
String ric=request.getParameter("ric");
String shi1=nianj+"-"+yuej+"-"+rij;
out.println(shi1);
String shi2=nianc+"-"+yuec+"-"+ric;
out.println(shi2);
String stat=request.getParameter("stat");
stat=new String(stat.getBytes("ISO8859-1"),"GB2312");
out.println(stat);
shi1=new String(shi1.getBytes("ISO8859-1"),"GB2312");
shi2=new String(shi2.getBytes("ISO8859-1"),"GB2312");
String sql = "update intent_form set status='"+stat+"',rectime='"+shi1+"',lastdealtime='"+shi2+"' where id='"+id+"'";
out.println(sql);
stmt.executeUpdate(sql);
//String sql="update 表名 set 字段一=?,字段二=?";
//PreparedStatement pstmt = con.prepareStatement(sql);
//pstmt.setString(1,参数1);
//pstmt.setString(2,参数2);
//pstmt.executeUpdate();
stmt.close();
}
|
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:cpic";
Connection con=DriverManager.getConnection(url,"sa","");
PreparedStatement updateacc;
String strSQL="UPDATE userinfo SET passw=? where usern='"+usern+"'";
updateacc = con.prepareStatement(strSQL);
updateacc.setString(1, pass);
updateacc.executeUpdate();
response.sendRedirect("usercharge.jsp");
con.close();
}catch(Exception e)
{out.println(e);}
稍微改一下吧
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:cpic";
Connection con=DriverManager.getConnection(url,"sa","");
PreparedStatement updateacc;
String strSQL="UPDATE userinfo SET passw=? where usern='"+usern+"'";
updateacc = con.prepareStatement(strSQL);
updateacc.setString(1, pass);
updateacc.executeUpdate();
response.sendRedirect("usercharge.jsp");
con.close();
}catch(Exception e)
{out.println(e);}
稍微改一下吧
|
看看sql语句有错没??可以单独执行一下看看。