/** * This method will create the plugin database * * @throws CantCreateDatabaseException */ private void createAssetIssuingTransactionDatabase() throws CantCreateDatabaseException { AssetIssuingTransactionDatabaseFactory databaseFactory = new AssetIssuingTransactionDatabaseFactory(this.pluginDatabaseSystem); assetIssuingDatabase = databaseFactory.createDatabase( pluginId, AssetIssuingTransactionDatabaseConstants.DIGITAL_ASSET_TRANSACTION_DATABASE); }
/** * This method open or creates the database i'll be working with * * @throws CantInitializeAssetIssuingTransactionDatabaseException */ public void initializeDatabase() throws CantInitializeAssetIssuingTransactionDatabaseException { try { /* * Open new database connection */ database = this.pluginDatabaseSystem.openDatabase(pluginId, pluginId.toString()); } catch (CantOpenDatabaseException cantOpenDatabaseException) { /* * The database exists but cannot be open. I can not handle this situation. */ throw new CantInitializeAssetIssuingTransactionDatabaseException( cantOpenDatabaseException.getMessage()); } catch (DatabaseNotFoundException e) { /* * The database no exist may be the first time the plugin is running on this device, * We need to create the new database */ AssetIssuingTransactionDatabaseFactory assetIssuingTransactionDatabaseFactory = new AssetIssuingTransactionDatabaseFactory(pluginDatabaseSystem); try { /* * We create the new database */ database = assetIssuingTransactionDatabaseFactory.createDatabase(pluginId, pluginId.toString()); } catch (CantCreateDatabaseException cantCreateDatabaseException) { /* * The database cannot be created. I can not handle this situation. */ throw new CantInitializeAssetIssuingTransactionDatabaseException( cantCreateDatabaseException.getMessage()); } } }