use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException in project binnavi by google.
the class PostgreSQLHelpers method deleteById.
/**
* Deletes a row that is identified by an ID from a table.
*
* @param connection Connection to the SQL database.
* @param tableName Name of the table from which the row is deleted.
* @param id ID of the row to delete.
*
* @throws CouldntDeleteException Thrown if the row could not be deleted.
*/
public static void deleteById(final CConnection connection, final String tableName, final int id) throws CouldntDeleteException {
Preconditions.checkNotNull(connection, "IE00595: Connection argument can not be null");
Preconditions.checkNotNull(tableName, "IE00596: Table name argument can not be null");
Preconditions.checkArgument(id > 0, "IE00597: Id argument can not be less or equal zero");
try {
connection.executeUpdate(String.format("DELETE FROM %s WHERE id = %d", tableName, id), true);
} catch (final SQLException e) {
throw new CouldntDeleteException(e);
}
}
use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException in project binnavi by google.
the class DebuggerTemplateManager method removeDebugger.
/**
* Removes a debugger template from the database.
*
* @param debugger The debugger template to be removed.
*
* @throws CouldntDeleteException Thrown if the debugger template could not be removed from the
* database.
*/
public void removeDebugger(final DebuggerTemplate debugger) throws CouldntDeleteException {
Preconditions.checkNotNull(debugger, "IE00812: Debugger argument can not be null");
Preconditions.checkArgument(debugger.inSameDatabase(sqlProvider), "IE00813: Debugger template and debugger template manager are not in the same database");
sqlProvider.deleteDebugger(debugger);
debuggers.remove(debugger);
for (final IDebuggerTemplateManagerListener listener : listeners) {
try {
listener.removedDebugger(this, debugger);
} catch (final Exception e) {
CUtilityFunctions.logException(e);
}
}
}
Aggregations