Search in sources :

Example 41 with CouldntDeleteException

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);
    }
}
Also used : CouldntDeleteException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException) SQLException(java.sql.SQLException)

Example 42 with CouldntDeleteException

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);
        }
    }
}
Also used : IDebuggerTemplateManagerListener(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebuggerTemplateManagerListener) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntDeleteException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)

Aggregations

CouldntDeleteException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)42 SQLException (java.sql.SQLException)27 CallableStatement (java.sql.CallableStatement)15 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)8 CDefaultProgressOperation (com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation)8 CConnection (com.google.security.zynamics.binnavi.Database.CConnection)7 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)5 PreparedStatement (java.sql.PreparedStatement)5 IDatabaseListener (com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener)3 MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)3 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)3 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)2 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)2 ArrayList (java.util.ArrayList)2 LoadCancelledException (com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)1 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)1 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)1 IUserManagerListener (com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUserManagerListener)1 DebuggerTemplate (com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate)1 IDebuggerTemplateManagerListener (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebuggerTemplateManagerListener)1