/** * Check if throwable contains message about invalid time zone. * @param e * @return true if timezone invalid */ public static boolean isTimezoneInvalid(Throwable e) { if (throwableContainsMessage(e, "ORA-01882") // Oracle "ORA-01882: timezone region not found" // Doesn't seem to matter anywhere else right now. ) { return true; } return false; }
private void put(List<Object[]> args) { try { String prefixedTableName = prefixedTableNames.get(tableRef, conns); conns.get().insertManyUnregisteredQuery("/* INSERT_ONE (" + prefixedTableName + ") */" + " INSERT INTO " + prefixedTableName + " (row_name, col_name, ts, val) " + " VALUES (?, ?, ?, ?) ", args); } catch (PalantirSqlException e) { if (ExceptionCheck.isUniqueConstraintViolation(e)) { throw new KeyAlreadyExistsException("primary key violation", e); } throw e; } }
connConfig.getConnectionPoolName(), connConfig.getUrl(), e); if (ExceptionCheck.isTimezoneInvalid(e)) { String tzname = TimeZone.getDefault().getID();
if (!ExceptionCheck.isUniqueConstraintViolation(e)) { throw e;
connConfig.getConnectionPoolName(), connConfig.getUrl(), e); if (ExceptionCheck.isTimezoneInvalid(e)) { String tzname = TimeZone.getDefault().getID();
} catch (PalantirSqlException e) { if (!ExceptionCheck.isUniqueConstraintViolation(e)) { throw e;
/** * Check if throwable contains message about unique constraint violation. * @param e * @return true if unique constraint violation */ public static boolean isUniqueConstraintViolation(Throwable e) { if (throwableContainsMessage(e, "ORA-00001") // Oracle "ORA-00001: unique constraint <constraint name> violated" || throwableContainsMessage(e, "duplicate key value violates unique constraint") // PostgreSQL "ERROR: duplicate key violates unique constraint" || throwableContainsMessage(e, "Unique index or primary key violation") // H2 "SEVERE: Unique index or primary key violation" || throwableContainsMessage(e, "SQLITE_CONSTRAINT") // SQLite ) { return true; } return false; }
private void put(List<Object[]> args, List<Object[]> overflowArgs) { if (!overflowArgs.isEmpty()) { if (config.overflowMigrationState() == OverflowMigrationState.UNSTARTED) { conns.get().insertManyUnregisteredQuery("/* INSERT_OVERFLOW */" + " INSERT INTO " + config.singleOverflowTable() + " (id, val) VALUES (?, ?) ", overflowArgs); } else { String shortOverflowTableName = getShortOverflowTableName(); conns.get().insertManyUnregisteredQuery( "/* INSERT_OVERFLOW (" + shortOverflowTableName + ") */" + " INSERT INTO " + shortOverflowTableName + " (id, val) VALUES (?, ?) ", overflowArgs); } } try { String shortTableName = oraclePrefixedTableNames.get(tableRef, conns); conns.get().insertManyUnregisteredQuery("/* INSERT_ONE (" + shortTableName + ") */" + " INSERT INTO " + shortTableName + " (row_name, col_name, ts, val, overflow) " + " VALUES (?, ?, ?, ?, ?) ", args); } catch (PalantirSqlException e) { if (ExceptionCheck.isUniqueConstraintViolation(e)) { throw new KeyAlreadyExistsException("primary key violation", e); } throw e; } }
/** * Check if throwable contains message about foreign key constraint violation. * @param e * @return true if foreign key constraint violation */ public static boolean isForeignKeyConstraintViolation(Throwable e) { if (throwableContainsMessage(e, "ORA-02291") // Oracle "ORA-02291: integrity constraint <constraint name> violated - parent key not found" || throwableContainsMessage(e, "ORA-02292") // Oracle "ORA-02292: integrity constraint <constraint name> violated - child record found" || throwableContainsMessage(e, "violates foreign key constraint") // PostgreSQL "ERROR: insert or update on table "<constraint name>" violates foreign key constraint "<constraint name> "" || throwableContainsMessage(e, "Referential integrity constraint violation") // H2 "SEVERE: Referential integrity constraint violation" || throwableContainsMessage(e, "SQLITE_CONSTRAINT") // SQLite ) { return true; } return false; }
private void put(List<Object[]> args) { try { String prefixedTableName = prefixedTableNames.get(tableRef, conns); conns.get().insertManyUnregisteredQuery("/* INSERT_ONE (" + prefixedTableName + ") */" + " INSERT INTO " + prefixedTableName + " (row_name, col_name, ts, val) " + " VALUES (?, ?, ?, ?) ", args); } catch (PalantirSqlException e) { if (ExceptionCheck.isUniqueConstraintViolation(e)) { throw new KeyAlreadyExistsException("primary key violation", e); } throw e; } }
/** * Check if throwable contains message about invalid time zone. * @param e * @return true if timezone invalid */ public static boolean isTimezoneInvalid(Throwable e) { if (throwableContainsMessage(e, "ORA-01882") // Oracle "ORA-01882: timezone region not found" // Doesn't seem to matter anywhere else right now. ) { return true; } return false; }
if (!ExceptionCheck.isUniqueConstraintViolation(e)) { throw e;
/** * Check if throwable contains message about foreign key constraint violation. * @param e * @return true if foreign key constraint violation */ public static boolean isForeignKeyConstraintViolation(Throwable e) { if (throwableContainsMessage(e, "ORA-02291") // Oracle "ORA-02291: integrity constraint <constraint name> violated - parent key not found" || throwableContainsMessage(e, "ORA-02292") // Oracle "ORA-02292: integrity constraint <constraint name> violated - child record found" || throwableContainsMessage(e, "violates foreign key constraint") // PostgreSQL "ERROR: insert or update on table "<constraint name>" violates foreign key constraint "<constraint name> "" || throwableContainsMessage(e, "Referential integrity constraint violation") // H2 "SEVERE: Referential integrity constraint violation" || throwableContainsMessage(e, "SQLITE_CONSTRAINT") // SQLite ) { return true; } return false; }
} catch (PalantirSqlException e) { if (!ExceptionCheck.isUniqueConstraintViolation(e)) { throw e;
/** * Check if throwable contains message about unique constraint violation. * @param e * @return true if unique constraint violation */ public static boolean isUniqueConstraintViolation(Throwable e) { if (throwableContainsMessage(e, "ORA-00001") // Oracle "ORA-00001: unique constraint <constraint name> violated" || throwableContainsMessage(e, "duplicate key value violates unique constraint") // PostgreSQL "ERROR: duplicate key violates unique constraint" || throwableContainsMessage(e, "Unique index or primary key violation") // H2 "SEVERE: Unique index or primary key violation" || throwableContainsMessage(e, "SQLITE_CONSTRAINT") // SQLite ) { return true; } return false; }
private void put(List<Object[]> args, List<Object[]> overflowArgs) { if (!overflowArgs.isEmpty()) { if (config.overflowMigrationState() == OverflowMigrationState.UNSTARTED) { conns.get().insertManyUnregisteredQuery("/* INSERT_OVERFLOW */" + " INSERT INTO " + config.singleOverflowTable() + " (id, val) VALUES (?, ?) ", overflowArgs); } else { String shortOverflowTableName = getShortOverflowTableName(); conns.get().insertManyUnregisteredQuery( "/* INSERT_OVERFLOW (" + shortOverflowTableName + ") */" + " INSERT INTO " + shortOverflowTableName + " (id, val) VALUES (?, ?) ", overflowArgs); } } try { String shortTableName = oraclePrefixedTableNames.get(tableRef, conns); conns.get().insertManyUnregisteredQuery("/* INSERT_ONE (" + shortTableName + ") */" + " INSERT INTO " + shortTableName + " (row_name, col_name, ts, val, overflow) " + " VALUES (?, ?, ?, ?, ?) ", args); } catch (PalantirSqlException e) { if (ExceptionCheck.isUniqueConstraintViolation(e)) { throw new KeyAlreadyExistsException("primary key violation", e); } throw e; } }