java tomcat报错

wenwen1 发布于 2012/08/28 15:34
阅读 1K+
收藏 0
<%@ page language="java" import="java.util.*" import="java.sql.*" pageEncoding="utf-8"%>
<jsp:useBean id="dbConn" class="pack_convert.DBConnXmgl"/>
<jsp:useBean id="systemRelated" class="net.gvsun.database.SystemRelated"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   
    <title>newProjectFinance</title>

<link rel="stylesheet" type="text/css" href="../../jquery/themes/default/easyui.css">
    <script type="text/javascript">
  function doCheck(){
    if(cash.hkrq.value==""){
      alert("请输入回款日期!");
      cash.hkrq.focus();
      return false;
    }
    else if(cash.hkje.value==""){
      alert("请输入回款金额!");
      cash.hkje.focus();
      return false;
    }
    else if(cash.hkr.value==""){
        alert("请输入回款人!");
        cash.hkr.focus();
        return false;
      }
    else{
      return true;
    }
  }
</script>
  </head>
 
  <body>
<%
String datenow = systemRelated.getDateNow();
request.setCharacterEncoding("utf-8");//处理乱码
String xmbh= request.getParameter("xmbh");
%> 
<form action="newCashSub.jsp" method="post" name="cash" onSubmit="return doCheck()"> 
<table width="95%" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td width="12%"><strong>项目编号*</strong></td>
    <td width="12%"><strong>回款日期*</strong></td>
    <td width="15%"><strong>回款金额*</strong></td>
    <td width="15%"><strong>回款方式</strong></td>
    <td width="10%"><strong>回款人*</strong></td>
    <td width="36%"><strong>说明</strong></td>
  </tr>
  <tr>
    <td><input type="text" name="xmbh" size="20" value=<%=(xmbh==null)?"":xmbh%> ></td>
    <td><input type="text" name="hkrq" value='<%=datenow %>'></td>
    <td><input type="text" name="hkje" value="0"></td>
    <td><input type="text" name="hkfs"></td>
    <td>
<div style="position:relative;">
<span style="margin-left:100px;width:18px;overflow:hidden;">
<select name="xmjda" style="width:118px;margin-left:-100px" onchange="this.parentNode.nextSibling.value=this.value">
 <option value=""></option>
<%
String sql = "select userId,userName,phone from user order by userId asc";
ResultSet rs2 = dbConn.doQuery(sql);
while(rs2.next()){
    String auserName = rs2.getString("userName");
%>
      <option value="<%=auserName %>"><%=auserName %></option>
<%
}
%>
</select></span><input name="hkr" style="width:100px;position:absolute;left:0px;">
</div>    
    </td>
    <td><textarea name="sm" rows="5" cols="30"></textarea></td>
    </tr>
</table>
   <p align="center">
    <input type="submit" name="Submit" value="提交">
  </p>
</form>  
<center>
<%
session.setAttribute("KEYWORD",xmbh);
%> 
</center>
  </body>

</html>

我的newCashSub.jsp如下:

<%@ page language="java" import="java.util.*" import="java.sql.*" pageEncoding="utf-8"%>
<jsp:useBean id="dbConn" class="pack_convert.DBConnXmgl"/>
<jsp:useBean id="systemRelated" class="net.gvsun.database.SystemRelated"/>
<%@ page session="true" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   
    <title>newCashSub</title>

  </head>
 
  <body>
  <%
  request.setCharacterEncoding("utf-8");//处理乱码
  String xmbh = (String)session.getAttribute("xmbh");
  String hkrq = request.getParameter("hkrq");
  String hkje = request.getParameter("hkje");
  String hkfs = request.getParameter("hkfs");
  String hkr = request.getParameter("hkr");
  String sm = request.getParameter("sm");
  String createdBy = (String)session.getAttribute("userName");
  String editedBy = (String)session.getAttribute("userName");
  String datetimenow = systemRelated.getDateTimeNow();
String sql = "insert into project_cash(xmbh,hkrq,hkje,hkfs,hkr,sm,createdBy,createdOn,editedBy,editedOn) values ('"+xmbh+"','"+hkrq+"','"+hkje+"','"+hkfs+"','"+hkr+"','"+sm+"','"+createdBy+"','"+datetimenow+"','"+editedBy+"','"+datetimenow+"')";
  boolean bol = dbConn.Sql(sql);
  if(bol){
       out.println("添加成功!");
   }else{
       out.println("出错了,请重新操作!");
   }
  dbConn.releaseConn();//释放链接
  response.setHeader("Refresh","1; URL=../../projectFinance.jsp");//12秒后自动跳转页面

  %>   
  </body>
</html>
tomcat报错:

com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`pwy`.`project_cash`, CONSTRAINT `FK_project_cash_1` FOREIGN KEY (`xmbh`) REFERENCES `project` (`xmbh`) ON DELETE CASCADE ON UPDATE CASCADE)
java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Date
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
    at com.mysql.jdbc.ResultSet.getDateFromString(ResultSet.java:2048)
    at com.mysql.jdbc.ResultSet.getStringInternal(ResultSet.java:5732)
    at com.mysql.jdbc.ResultSet.getString(ResultSet.java:5544)
    at org.apache.commons.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:149)
    at pack_convert.Convert.getMap(Convert.java:59)
    at pack_convert.Convert.getConResult(Convert.java:88)
    at net.gvsun.database.ProjectInfo.getCashList(ProjectInfo.java:51)
    at org.apache.jsp.projectinfo.json.getCashList_jsp._jspService(getCashList_jsp.java:70)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:662)


加载中
0
情天大圣
情天大圣
Value '0000-00-00' can not be represented as java.sql.Date
wenwen1
wenwen1
啊呀,你说了跟没说似的,令我好失望啊。
0
Bless_you
Bless_you
报错是说主外键问题,你去看看。
wenwen1
wenwen1
嗯,懂了。谢啦
返回顶部
顶部