You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by erosik <er...@gmail.com> on 2008/02/15 14:09:45 UTC
com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException
Hi,
i am using ibatis in my jsp application, i have created db with a
unique field (e.g. id) so when i insert a record with same id again i m
getting error like this, can any one help to sort out this exception
com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException:
Duplicate
entry '123' for key 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:931)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2822)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1536)
at
com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1159)
at
com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:684)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:768)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
com.ibatis.common.jdbc.logging.PreparedStatementLogProxy.invoke(PreparedStatementLogProxy.java:62)
at $Proxy1.execute(Unknown Source)
at
com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:81)
at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteUpdate(GeneralStatement.java:200)
at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:78)
at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:447)
at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:82)
at
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.insert(SqlMapClientImpl.java:59)
at _jsp._action__jsp._jspService(action.jsp:19)
at com.caucho.jsp.JavaPage.service(JavaPage.java:60)
at com.caucho.jsp.Page.pageservice(Page.java:570)
at
com.caucho.server.dispatch.PageFilterChain.doFilter(PageFilterChain.java:179)
at
com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:173)
at
com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:229)
at com.caucho.server.hmux.HmuxRequest.handleRequest(HmuxRequest.java:420)
at com.caucho.server.port.TcpConnection.run(TcpConnection.java:511)
at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:520)
at com.caucho.util.ThreadPool.run(ThreadPool.java:442)
at java.lang.Thread.run(Thread.java:595)
--
View this message in context: http://www.nabble.com/com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException-tp15500792p15500792.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
Re: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationExc
eption
Posted by Graeme J Sweeney <ib...@gjsweeney.com>.
On Fri, 15 Feb 2008, erosik wrote:
> i am using ibatis in my jsp application, i have created db with a
> unique field (e.g. id) so when i insert a record with same id again i m
> getting error like this, can any one help to sort out this exception
>
> com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException:
> Duplicate
> entry '123' for key 1
Sort out how?
If you have more than one 'id' with value '123' then you cannot use the
unique constraint. You need to alter the schema of the database to remove
it.
--
Graeme -