jsp的问题,insert语句总是insert不到数据库中,链接的是Mysql数据库,求高人指点,下边附上了本人的代码,万分的感激啊!!!

YO_OY 发布于 2011/12/15 10:59
阅读 959
收藏 0

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="JDBConnection.jdbfactory" %>
<%@ page import="java.sql.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>添加处理</title>

 <meta http-equiv="pragma" content="no-cache">
 <meta http-equiv="cache-control" content="no-cache">
 <meta http-equiv="expires" content="0">   
 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
 <meta http-equiv="description" content="This is my page">
 <!--
 <link rel="stylesheet" type="text/css" href="styles.css">
 -->

  </head>
 
  <body>
   <%!
   String sql=null;
   jdbfactory con=new jdbfactory();
   int flag=0;
    %>
    <%
    //获取tianjia.jsp所传的值
    String xingming=request.getParameter("xingming");
    String leixing=request.getParameter("leixing");
    String yewujingli=request.getParameter("yewujingli");
    String kehudianhua=request.getParameter("kehudianhua");
    String yinhangjingli=request.getParameter("yinhangjingli");
    String chexing=request.getParameter("chexing");
    String chejia=request.getParameter("chejia");
    String daikuanjine=request.getParameter("daikuanjine");
    String nianxian=request.getParameter("nianxian");
    String baoxianyajin=request.getParameter("baoxianyajin");
    String jiedairenyuan=request.getParameter("jiedairenyuan");
    String weizuocheng=request.getParameter("weizuochengyuanyin");
    String zhuangtai=request.getParameter("zhuangtai");
   // out.print(xingming);
   // out.print(leixing);
   // out.print(yewujingli);
   // out.print(kehudianhua);
   // out.print(yinhangjingli);
   // out.print(chexing);
   // out.print(chejia);
   // out.print(daikuanjine);
    //out.print(nianxian);
    //out.print(baoxianyajin);
    //out.print(jiedairenyuan);
    //out.print(weizuocheng);
    //out.print(zhuangtai);
    sql="insert into jiedaibu values('','"+xingming+"','"+leixing+"','"+yewujingli+"','"+kehudianhua+"','"+yinhangjingli+"','"+chexing+"','"+chejia+"','"+daikuanjine+"','"+nianxian+"','"+baoxianyajin+"','"+jiedairenyuan+"','"+weizuocheng+"','"+zhuangtai+"')";
    flag=con.doUpdate(sql);
    try{
    if(flag==0){%>
    <script type="text/javascript">
    alert("添加失败!");
    window.history.back(-1);
    </script>   
    <%
    }else{%>
    <script type="text/javascript">
    alert("添加成功!");
    window.history.go(-1);
    </script>
    <%   
    }}catch(Exception e){
    out.print(e);
    }
     %>
  </body>
</html>

加载中
0
pyawen
pyawen

这种问题 自己打印一下sql语句,然后到数据库里面去执行一下 看有什么语法错误没

如果没有的话 在查找代码里面的问题

 

pyawen
pyawen
@Tiffany_Coco : doUpdate 代码是怎么样
YO_OY
YO_OY
sql语句我打印了,sql语句完全没有问题,可以添加到数据库中,可是就是到页面了之后就总是走flag==0,总是添加不进去,数据获取也没有任何问题,这是为什么呀,太谢谢您了,能再给解决一下吗?太谢谢您了
返回顶部
顶部