Search in sources :

Example 1 with MacAddressBookProxyDatabaseHandler

use of de.janrufmonitor.repository.MacAddressBookProxyDatabaseHandler in project janrufmonitor by tbrandt77.

the class MacAddressBookProxy method start.

public synchronized void start() {
    if (this.m_dbh == null) {
        String db_path = PathResolver.getInstance(this.getRuntime()).resolve(PathResolver.getInstance(this.getRuntime()).getDataDirectory() + "macab_cache" + File.separator + "macab_mapping.db");
        db_path = StringUtils.replaceString(db_path, "\\", "/");
        File db = new File(db_path + ".properties");
        boolean initialize = false;
        if (!db.exists()) {
            initialize = true;
            db.getParentFile().mkdirs();
            try {
                File db_raw = new File(db_path);
                if (!db_raw.exists()) {
                    ZipArchive z = new ZipArchive(db_path);
                    z.open();
                    z.close();
                }
            } catch (ZipArchiveException e) {
                this.m_logger.log(Level.SEVERE, e.getMessage(), e);
            }
        }
        this.m_dbh = new MacAddressBookProxyDatabaseHandler("org.hsqldb.jdbcDriver", "jdbc:hsqldb:file:" + db_path, "sa", "", initialize);
        try {
            this.m_dbh.connect();
        } catch (SQLException e) {
            this.m_logger.log(Level.SEVERE, e.getMessage(), e);
        } catch (ClassNotFoundException e) {
            this.m_logger.log(Level.SEVERE, e.getMessage(), e);
        }
    }
}
Also used : ZipArchiveException(de.janrufmonitor.repository.zip.ZipArchiveException) MacAddressBookProxyDatabaseHandler(de.janrufmonitor.repository.MacAddressBookProxyDatabaseHandler) SQLException(java.sql.SQLException) ZipArchive(de.janrufmonitor.repository.zip.ZipArchive) File(java.io.File)

Aggregations

MacAddressBookProxyDatabaseHandler (de.janrufmonitor.repository.MacAddressBookProxyDatabaseHandler)1 ZipArchive (de.janrufmonitor.repository.zip.ZipArchive)1 ZipArchiveException (de.janrufmonitor.repository.zip.ZipArchiveException)1 File (java.io.File)1 SQLException (java.sql.SQLException)1