Search in sources :

Example 1 with PostgreSQLNotificationProvider

use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.PostgreSQLNotificationProvider in project binnavi by google.

the class CDatabase method connect.

@Override
public void connect() throws CouldntLoadDriverException, CouldntConnectException, InvalidDatabaseException, CouldntInitializeDatabaseException, InvalidExporterDatabaseFormatException, LoadCancelledException {
    loadReporter.start();
    isConnecting = true;
    try {
        final Pair<CConnection, SQLProvider> connectionData = CDatabaseConnection.connect(description, loadReporter);
        provider = connectionData.second();
    } catch (final CouldntLoadDriverException exception) {
        loadReporter.report(LoadEvents.LOADING_FINISHED);
        throw exception;
    } catch (final CouldntConnectException exception) {
        loadReporter.report(LoadEvents.LOADING_FINISHED);
        throw exception;
    } catch (final CouldntInitializeDatabaseException exception) {
        loadReporter.report(LoadEvents.LOADING_FINISHED);
        throw exception;
    } catch (final InvalidDatabaseException exception) {
        loadReporter.report(LoadEvents.LOADING_FINISHED);
        throw exception;
    } catch (final InvalidExporterDatabaseFormatException exception) {
        loadReporter.report(LoadEvents.LOADING_FINISHED);
        throw exception;
    } catch (final LoadCancelledException exception) {
        loadReporter.report(LoadEvents.LOADING_FINISHED);
        throw exception;
    } finally {
        isConnecting = false;
    }
    for (final IDatabaseListener listener : listeners) {
        try {
            listener.openedDatabase(this);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
    try {
        final PostgreSQLNotificationProvider notificationProvider = PostgreSQLNotificationProvider.initialize(provider, description);
        notificationProvider.listen(NotificationChannel.all());
        notificationProvider.startPolling();
    } catch (final SQLException exception) {
        NaviLogger.severe("Error: Could not establish a channel for receiving notifications from the database %s", exception);
    }
}
Also used : SQLException(java.sql.SQLException) CouldntInitializeDatabaseException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntInitializeDatabaseException) InvalidExporterDatabaseFormatException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidExporterDatabaseFormatException) SQLProvider(com.google.security.zynamics.binnavi.Database.Interfaces.SQLProvider) IDatabaseListener(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) CouldntInitializeDatabaseException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntInitializeDatabaseException) CouldntLoadDriverException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDriverException) InvalidExporterDatabaseFormatException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidExporterDatabaseFormatException) SQLException(java.sql.SQLException) InvalidDatabaseException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseException) CouldntConnectException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntConnectException) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CouldntUpdateDatabaseException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntUpdateDatabaseException) InvalidDatabaseVersionException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseVersionException) CouldntLoadDriverException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDriverException) PostgreSQLNotificationProvider(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.PostgreSQLNotificationProvider) InvalidDatabaseException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseException) CouldntConnectException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntConnectException) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)

Aggregations

CouldntConnectException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntConnectException)1 CouldntInitializeDatabaseException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntInitializeDatabaseException)1 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)1 CouldntLoadDriverException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDriverException)1 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)1 CouldntUpdateDatabaseException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntUpdateDatabaseException)1 InvalidDatabaseException (com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseException)1 InvalidDatabaseVersionException (com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseVersionException)1 InvalidExporterDatabaseFormatException (com.google.security.zynamics.binnavi.Database.Exceptions.InvalidExporterDatabaseFormatException)1 LoadCancelledException (com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)1 IDatabaseListener (com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener)1 SQLProvider (com.google.security.zynamics.binnavi.Database.Interfaces.SQLProvider)1 PostgreSQLNotificationProvider (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.PostgreSQLNotificationProvider)1 SQLException (java.sql.SQLException)1