NutzCN Logo
问答 在插入一条记录的时候 报了这个错误 求大神指点一下
发布于 3010天前 作者 qq_722cb381 2708 次浏览 复制 上一个帖子 下一个帖子
标签:

For example:> "INSERT INTO t_role(r_name,r_desc,r_installed) VALUES('admin','超级管理员',true) "
08-19 13:32:23.081 DEBUG - [Statement.localhost-startStop-1] {conn-10010, pstmt-20070} created.
INSERT INTO t_role(r_name,r_desc,r_installed) VALUES(?,?,?)
08-19 13:32:23.082 DEBUG - [Statement.localhost-startStop-1] {conn-10010, pstmt-20070} Parameters : [admin, 超级管理员, true]
08-19 13:32:23.082 DEBUG - [Statement.localhost-startStop-1] {conn-10010, pstmt-20070} Types : [VARCHAR, VARCHAR, BOOLEAN]
08-19 13:32:23.092 ERROR - [Statement.localhost-startStop-1] {conn-10010, pstmt-20070} execute error. INSERT INTO t_role(r_name,r_desc,r_installed) VALUES(?,?,?)
java.sql.SQLException: Field 'id' doesn't have a default value
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:959)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3870)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3806)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2470)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2617)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2550)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1192)
at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2931)
at com.alibaba.druid.filter.FilterAdapter.preparedStatement_execute(FilterAdapter.java:1058)
at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2929)
at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_execute(FilterEventAdapter.java:440)
at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2929)
at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_execute(FilterEventAdapter.java:440)
at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2929)
at com.alibaba.druid.wall.WallFilter.preparedStatement_execute(WallFilter.java:602)
at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2929)
at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.execute(PreparedStatementProxyImpl.java:131)
at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:493)
at org.nutz.dao.impl.sql.run.NutDaoExecutor._runPreparedStatement(NutDaoExecutor.java:268)
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:82)
at org.nutz.dao.impl.DaoSupport$DaoExec.invoke(DaoSupport.java:334)
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:59)
at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:257)
at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:289)
at org.nutz.dao.impl.EntityOperator.exec(EntityOperator.java:50)
at org.nutz.dao.impl.NutDao.insert(NutDao.java:158)
at club.zhcs.titans.utils.biz.BaseService.save(BaseService.java:66)
at club.zhcs.thunder.biz.acl.RoleService$$NUTZAOP._aop_invoke(RoleService.java:14)
at org.nutz.aop.InterceptorChain.invoke(InterceptorChain.java:77)
at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:57)
at org.nutz.aop.interceptor.LoggingMethodInterceptor.filter(LoggingMethodInterceptor.java:48)
at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60)
at club.zhcs.thunder.biz.acl.RoleService$$NUTZAOP.save(RoleService.java:1)
at club.zhcs.thunder.ThunderSetup.init(ThunderSetup.java:127)
at org.nutz.mvc.impl.NutLoading.evalSetup(NutLoading.java:276)
at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:120)
at org.nutz.mvc.ActionHandler.(ActionHandler.java:19)
at org.nutz.mvc.NutFilter._init(NutFilter.java:87)
at org.nutz.mvc.NutFilter.init(NutFilter.java:65)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4841)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5535)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

3 回复

属性标注了@Id,但数据库表中的字段不是自增,就会报这个错误.

@wendal 谢谢大神 建表的时候忘设置了

自动建表不够用?

来自炫酷的 NutzCN

添加回复
请先登陆
回到顶部