HTTP Status 500 - javax.servlet.ServletException: java.sql.SQLException: Column count doesn't match value count at row 1
type Exception reportmessage javax.servlet.ServletException: java.sql.SQLException: Column count doesn't match value count at row 1description The server encountered an internal error that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: javax.servlet.ServletException: java.sql.SQLException: Column count doesn't match value count at row 1
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
root cause javax.servlet.ServletException: java.sql.SQLException: Column count doesn't match value count at row 1
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:912)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:841)
org.apache.jsp.regAction_jsp._jspService(regAction_jsp.java:102)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
root cause java.sql.SQLException: Column count doesn't match value count at row 1
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498)
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113)
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2568)
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2113)
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2409)
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2327)
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2312)
org.apache.jsp.regAction_jsp._jspService(regAction_jsp.java:89)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
==========================================================================
下面这个往数据库插入信息 
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="include_head.jsp"%><% 
 //接收之前页面传递过来的URL参数
    request.setCharacterEncoding("utf-8");
    String username =request.getParameter("username");
    String password =request.getParameter("password");
    String name =request.getParameter("name");
    String sex =request.getParameter("sex");
   
   Connection conn=DBUtil.getConn();
   PreparedStatement pstmt = DBUtil.getPstmt(conn,"insert into t_user values(null,?,?,?,?)");
   pstmt.setString(1,username);
   pstmt.setString(2,password);
   pstmt.setString(3,name);
   pstmt.setString(4,sex);
   pstmt.executeUpdate();
%>
<jsp:forward page="index.jsp"></jsp:forward>
数据库异常JavaStringUTF-8

解决方案 »

  1.   

    呼呼 你数据表的第一个字段是不是count?然后你还用null去更新他出了问题撒
      

  2.   

    t_user有几个字段?是否也是五个?第一个不要赋值了,去掉null看看。
    insert into t_user values(null,?,?,?,?)插入值,最好指定插入谁,比如insert into t_user(c1,c2,c3,c4,c5) values(null,?,?,?,?)这样就不会错了。
      

  3.   

    Column count doesn't match value count at row 1
    这里提示的多明显了.
    列(字段)数不能匹配值的个数insert into t_user values(null,?,?,?,?)
    你的t_user表中字段个数不是五个吧.
    就像楼上说的,把t_user要插入的字段列出来  
    insert into t_usr(co1,co2,co3,co4,c5) values(?,?,?,?,?)
    要不就把值补齐,有几个字段就跟几个值.