• Caused by: java.sql.SQLException: Field 'stu_id' doesn't have a default value


    1、错误描述

    ### Cause: java.sql.SQLException: Field 'stu_id' doesn't have a default value
    ; SQL []; Field 'line_id' doesn't have a default value; nested exception is java.sql.SQLException: Field 'stu_id' doesn't have a default value
    	at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:243)
    	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
    	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71)
    	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:364)
    	at com.sun.proxy.$Proxy18.insert(Unknown Source)
    	at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:236)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    	at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208))
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
    	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
    	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
    	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2517)
    	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2506)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    	at java.lang.Thread.run(Thread.java:745)
    Caused by: java.sql.SQLException: Field 'stu_id' doesn't have a default value
    	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:996)
    	at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:137)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:606)
    	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:354)
    	... 98 more

    2、错误原因

          在做学生信息表插入操作时,stu_id字段(主键)不是自增长的,前台也没有传值,导致报错


    3、解决办法

    (1)前台添加stu_id录入框

    (2)后台拼接SQL语句,需要加上stu_id

  • 相关阅读:
    在 jQuery Repeater 中为多个字段排序
    使用 AjaxManager 生成调用服务器端方法的 javascript 函数
    使用 JQueryElement ResponseProgress 显示页面执行进度
    (原创)反ARP攻击的绝招,让你在ARP的炮雨攻击下永不掉线
    (原创)最详细可靠的Cadence16.01破解crack和安装方法步骤
    (原创)PCI总线特性及信号说明
    (原创)Modelsim的“The system date appears to have been set back.Cannot continue”问题的解决办法
    爱你哦
    为ASP.NET封装的SQL数据库访问类
    JavaScript中的高级特性及特别对象、属性和方法
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13313976.html
Copyright © 2020-2023  润新知