美文网首页
com.mysql.jdbc.exceptions.jdbc4.

com.mysql.jdbc.exceptions.jdbc4.

作者: 牛哞哞杂记 | 来源:发表于2019-11-01 13:03 被阅读0次

    问题:
    java异常:
    com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry ‘oqKQM5LBRj2iwTG6zzGwlgPWuNjE-2019-10-31 14:38:14’ for key ‘openid’

    数据库异常:
    [Err] 1062 - Duplicate entry ‘oqKQM5LBRj2iwTG6zzGwlgPWuNjE-2019-11-01 09:49:59’ for key ‘openid’

    原因:
    关键字’openid’的重复条目’ oqkqm5lbrj2iwtg6zzlgpwunjj -2019-10-31 14:38:14’
    数据库的表里设置了同一openId不允许出现重复startTime的唯一键,下面这行sql

    UNIQUE KEY `openid` (`openid`,`startTime`) USING BTREE
    

    解决办法:
    推荐的解决办法是:按照表的设计,两个字段添加不重复的字段值
    不推荐的解决办法:去修改表的设计

    详细问题:
    com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry ‘oqKQM5LBRj2iwTG6zzGwlgPWuNjE-2019-10-31 14:38:14’ for key ‘openid’
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
    at com.mysql.jdbc.Util.getInstance(Util.java:382)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1039)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3603)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3535)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1989)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2150)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2626)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2333)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2318)

    相关文章

      网友评论

          本文标题:com.mysql.jdbc.exceptions.jdbc4.

          本文链接:https://www.haomeiwen.com/subject/pvufbctx.html