起步软件技术论坛
搜索
 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1903|回复: 3

[结贴] 外卖案例保存不了用户信息

[复制链接]

6

主题

14

帖子

74

积分

初级会员

Rank: 2

积分
74
QQ
发表于 2016-4-3 14:35:34 | 显示全部楼层 |阅读模式
跟外面案例一样的保存方法,结果还是错误
1.studio报错Duplicate entry 'user' for key 'PRIMARY';
2.save]执行失败,SQL执行失败,SQL:INSERT INTO takeout_user (fID,fAddress,fName,fPhoneNumber)  VALUES (?,?,?,?)
求解

Servlet.service() for servlet WeX5_Baas_Servlet threw exception
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'user' for key 'PRIMARY'
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:400)
        at com.mysql.jdbc.Util.getInstance(Util.java:383)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:973)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3847)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3783)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2447)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2594)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2545)
        at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1901)
        at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1193)
        at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
        at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
        at com.justep.baas.data.DataUtils.saveData(Unknown Source)
        at com.justep.baas.data.DataUtils.saveData(Unknown Source)
        at com.justep.baas.action.CRUD.save(Unknown Source)
        at lunch.LUNCHtime__do.save(LUNCHtime__do.java:107)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at com.justep.baas.action.Engine.execAction(Unknown Source)
        at com.justep.baas.action.Engine.execAction(Unknown Source)
        at com.justep.baas.servlet.BaasServlet.execService(Unknown Source)
        at com.justep.baas.servlet.BaasServlet.service(Unknown Source)
        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:103)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:745)

com.justep.baas.action.ActionException: Action[lunch/LUNCHtime/save]执行失败,SQL执行失败,SQL:INSERT INTO takeout_user (fID,fAddress,fName,fPhoneNumber)  VALUES (?,?,?,?)
        at com.justep.baas.action.Engine.execAction(Unknown Source)
        at com.justep.baas.action.Engine.execAction(Unknown Source)
        at com.justep.baas.servlet.BaasServlet.execService(Unknown Source)
        at com.justep.baas.servlet.BaasServlet.service(Unknown Source)
        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:103)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        ... 16 more
Caused by: com.justep.baas.data.sql.SQLException: SQL执行失败,SQL:INSERT INTO takeout_user (fID,fAddress,fName,fPhoneNumber)  VALUES (?,?,?,?)
        at com.justep.baas.data.DataUtils.saveData(Unknown Source)
        at com.justep.baas.data.DataUtils.saveData(Unknown Source)
        at com.justep.baas.action.CRUD.save(Unknown Source)
        at lunch.LUNCHtime__do.save(LUNCHtime__do.java:107)
        ... 20 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'user' for key 'PRIMARY'
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:400)
        at com.mysql.jdbc.Util.getInstance(Util.java:383)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:973)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3847)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3783)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2447)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2594)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2545)
        at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1901)
        at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1193)
        at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
        at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
        ... 24 more

91

主题

13万

帖子

3万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
36067
发表于 2016-4-5 15:09:24 | 显示全部楼层
Duplicate entry 'user' for key 'PRIMARY'
插入的主键值重复了
远程的联系方法QQ1392416607,添加好友时,需在备注里注明其论坛名字及ID,公司等信息
发远程时同时也发一下帖子地址,方便了解要解决的问题  WeX5教程  WeX5下载



如按照该方法解决,请及时跟帖,便于版主结贴
回复 支持 反对

使用道具 举报

6

主题

14

帖子

74

积分

初级会员

Rank: 2

积分
74
QQ
 楼主| 发表于 2016-4-6 21:40:56 | 显示全部楼层
本帖最后由 ljb379814076 于 2016-4-6 21:44 编辑
jishuang 发表于 2016-4-5 15:09
Duplicate entry 'user' for key 'PRIMARY'
插入的主键值重复了

我是修改保存用户信息,userid重新赋值就好了。。。。可以结贴
回复 支持 反对

使用道具 举报

11

主题

41

帖子

87

积分

初级会员

Rank: 2

积分
87
QQ
发表于 2016-8-12 10:58:30 | 显示全部楼层
ljb379814076 发表于 2016-4-6 21:40
我是修改保存用户信息,userid重新赋值就好了。。。。可以结贴

请问
你是如何解决的,如何给userid重新赋值?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|X3技术论坛|Justep Inc.    

GMT+8, 2024-11-23 05:51 , Processed in 0.072925 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表