Added isDuplicateRowException() for determining whether or not an
exception was caused by inserting a duplicate row into a table that disallows such actions. git-svn-id: https://samskivert.googlecode.com/svn/trunk@63 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: MySQLRepository.java,v 1.1 2001/02/13 00:25:14 mdb Exp $
|
||||
// $Id: MySQLRepository.java,v 1.2 2001/03/01 22:59:51 mdb Exp $
|
||||
|
||||
package com.samskivert.jdbc;
|
||||
|
||||
@@ -38,4 +38,18 @@ public abstract class MySQLRepository extends Repository
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether or not the supplied SQL exception originated
|
||||
* from a duplicate row error.
|
||||
*
|
||||
* @return true if the exception was thrown because a duplicate row
|
||||
* was inserted into a table that does not allow such things, false if
|
||||
* the exception is not related to duplicate rows.
|
||||
*/
|
||||
protected boolean isDuplicateRowException (SQLException sqe)
|
||||
{
|
||||
String msg = sqe.getMessage();
|
||||
return (msg != null && msg.indexOf("Duplicate entry") != -1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user