@ Override public void init ( ) throws InitializationException { if ( null == embedded || "true" . equalsIgnoreCase ( embedded ) ) { Log . warn ( "Audit4j Database Handler runs on embedded mode. See " + ErrorGuide . ERROR_URL + "embeddeddb for further details." ) ; server = HSQLEmbededDBServer . getInstance ( ) ; db_driver = server . getDriver ( ) ; db_url = server . getNetworkProtocol ( ) + ":file:audit4jdb" ; if ( db_user == null ) { db_user = Utils . EMBEDED_DB_USER ; } if ( db_password == null ) { db_password = Utils . EMBEDED_DB_PASSWORD ; } server . setUname ( db_user ) ; server . setPassword ( db_password ) ; server . start ( ) ; } factory = ConnectionFactory . getInstance ( ) ; factory . setDataSource ( dataSource ) ; factory . setDriver ( getDb_driver ( ) ) ; factory . setUrl ( getDb_url ( ) ) ; factory . setUser ( getDb_user ( ) ) ; factory . setPassword ( getDb_password ( ) ) ; factory . setDataSourceClass ( db_datasourceClass ) ; factory . setAutoCommit ( db_pool_autoCommit ) ; if ( db_pool_connectionTimeout != null ) { factory . setConnectionTimeout ( db_pool_connectionTimeout ) ; } if ( db_pool_idleTimeout != null ) { factory . setIdleTimeout ( db_pool_idleTimeout ) ; } if ( db_pool_maximumPoolSize != null ) { factory . setMaximumPoolSize ( db_pool_maximumPoolSize ) ; } if ( db_pool_maxLifetime != null ) { factory . setMaxLifetime ( db_pool_maxLifetime ) ; } if ( db_pool_minimumIdle != null ) { factory . setMinimumIdle ( db_pool_minimumIdle ) ; } if ( getDb_connection_type ( ) != null && getDb_connection_type ( ) . equals ( POOLED_CONNECTION ) ) { factory . setConnectionType ( ConnectionType . POOLED ) ; } else if ( getDb_connection_type ( ) != null && getDb_connection_type ( ) . equals ( JNDI_CONNECTION ) ) { factory . setConnectionType ( ConnectionType . JNDI ) ; factory . setJndiDataSource ( getDb_jndi_datasource ( ) ) ; } else { factory . setConnectionType ( ConnectionType . SINGLE ) ; } factory . init ( ) ; try { getDaoForTable ( default_table_name ) ; } catch ( HandlerException e ) { throw new InitializationException ( "Unable to create tables" , e ) ; } }
Initialize database handler .