Heim  >  Artikel  >  Datenbank  >  So beheben Sie den MySQL-Fehler Doppelter Eintrag „Wert“ für Schlüssel „Feldname“

So beheben Sie den MySQL-Fehler Doppelter Eintrag „Wert“ für Schlüssel „Feldname“

WBOY
WBOYnach vorne
2023-06-02 23:52:021460Durchsuche

Wenn Sie auf ein solches Problem stoßen, bedeutet das, dass das Feld in Ihrer Datenbanktabelle einen eindeutigen Index hat. Daher können die neu hinzugefügten Daten in diesem Feld nicht wiederholt werden. Konkret können Sie die Tabelle öffnen und auf „Tabelleneinstellungen“ klicken. Verursacht durch: com.mysql.jdbc.Exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Doppelter Eintrag „Test“ für Schlüssel „teacher.uk_name“

bei sun.reflect. NativeConstructorAccessorImpl. newInstance0(Native Method)

bei sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)So beheben Sie den MySQL-Fehler Doppelter Eintrag „Wert“ für Schlüssel „Feldname“ bei sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

bei java.lang.reflect.Constructor.new Instanz (Konstruktor .java:423)
bei com.mysql.jdbc.Util.handleNewInstance(Util.java:425)

bei com.mysql.jdbc.Util.getInstance(Util.java:408)
bei com.mysql. jdbc.SQLError .createSQLException(SQLError.java:936)
bei com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3976)
bei. com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3912)
bei com. mysql .jdbc.MysqlIO.sendCommand(MysqlIO.java:2530)
bei com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683)
bei com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java: 2486)
bei com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858)
bei com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1197)
bei com.zaxxer.hikari.pool.ProxyPreparedStatement. ausführen(ProxyPreparedStatement .java:44)
bei com.zaxxer.hikari.pool.HikariProxyPreparedStatement.execute(HikariProxyPreparedStatement.java)
bei sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
bei sun.reflect.NativeMethodAccessorImpl.invoke( Native MethodAccessorImpl.java: 62)
bei sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
bei java.lang.reflect.Method.invoke(Method.java:498)
bei org.apache.ibatis.logging .jdbc.PreparedStatementLogger. invoke(PreparedStatementLogger.java:59)
bei com.sun.proxy.$Proxy118.execute(Unknown Source)
bei org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:47 )
bei org. apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)
bei sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
bei sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: 62)
bei sun .reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
bei java.lang.reflect.Method.invoke(Method.java:498)
bei org.apache.ibatis.plugin.Plugin.invoke( Plugin.java:63 )
bei com.sun.proxy.$Proxy116.update(Unbekannte Quelle)
bei com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.doUpdate(MybatisSimpleExecutor.java:54)
bei org.apache. ibatis.executor.BaseExecutor .update(BaseExecutor.java:117)
unter com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.update(MybatisCachingExecutor.java:83)
unter org.apache.ibatis.session.defaults.DefaultSqlSession. update(DefaultSqlSession .java :197)
bei org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:184)
bei sun.reflect.NativeMethodAccessorImpl.invoke0(Native)
Methode bei sun.reflect.NativeMethodAccessorImpl .invoke (NativeMethodAccessorImpl. java:62)
bei sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
bei java.lang.reflect.Method.invoke(Method.java:498)
bei org.mybatis.spring .SqlSessionTemplate$SqlSession Interceptor. invoke(SqlSessionTemplate.java:426)
 … 61 weitere


Klicken Sie auf die Tabelleneinstellungen, um den Index anzuzeigen


Das obige ist der detaillierte Inhalt vonSo beheben Sie den MySQL-Fehler Doppelter Eintrag „Wert“ für Schlüssel „Feldname“. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Stellungnahme:
Dieser Artikel ist reproduziert unter:yisu.com. Bei Verstößen wenden Sie sich bitte an admin@php.cn löschen