w***y 发帖数: 6251 | 1 因为我定义的table里面有些属性是UNIQUE的,所以往里插入数据的时候,遇到duplicate
insertion就会有error返回
java.sql.SQLException: ERROR: Cannot insert a duplicate key into unique index
protein_protname_key
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:94)
at org.postgresql.Connection.ExecSQL(Connection.java:398)
at org.postgresql.jdbc2.Statement.execute(Statement.java:130)
at org.postgresql.jdbc2.Statement.executeUpdate(Statement.java:73)
at CaptionProcessor.writeFacts(Capt |
Q**g 发帖数: 183 | 2 try {
your insertion statments here....
}catch (java.sql.SQLException e) {
String msg = e.getMessage();
if (msg==null||!msg.startsWith("ERROR: Cannot insert a duplicate key"))
throw e;
}
【在 w***y 的大作中提到】 : 因为我定义的table里面有些属性是UNIQUE的,所以往里插入数据的时候,遇到duplicate : insertion就会有error返回 : java.sql.SQLException: ERROR: Cannot insert a duplicate key into unique index : protein_protname_key : at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:94) : at org.postgresql.Connection.ExecSQL(Connection.java:398) : at org.postgresql.jdbc2.Statement.execute(Statement.java:130) : at org.postgresql.jdbc2.Statement.executeUpdate(Statement.java:73) : at CaptionProcessor.writeFacts(Capt
|
w***y 发帖数: 6251 | 3 thx a lot:)
【在 Q**g 的大作中提到】 : try { : your insertion statments here.... : }catch (java.sql.SQLException e) { : String msg = e.getMessage(); : if (msg==null||!msg.startsWith("ERROR: Cannot insert a duplicate key")) : throw e; : }
|