Holger's Java API

## com.antelmann.sql
Class SQLFactoryDatabase

    java.lang.Object
      com.antelmann.db.AbstractDatabase<Connection>
          com.antelmann.sql.SQLDatabase
              com.antelmann.sql.SQLFactoryDatabase

All Implemented Interfaces:
  Database<Connection>, LoginListener, LoggerProvider, QueryMechanism, Closeable, EventListener

Direct Known Subclasses:
  GDB

    public class SQLFactoryDatabase

extends SQLDatabase

provides a specialized sql database which only opens the connection upon transaction begin and then closes it on each commit/abort (and therefore uses a factory). The embedded database service is a `ConnectionWrapper` that only provides a connected connection during a transaction!

Since:
  10.09.2011, 02:54:04
Author:
  Holger Antelmann
See Also:
  `AbstractDatabase.getDatabaseService()`

Nested Class Summary

Nested classes/interfaces inherited from interface com.antelmann.db.LoginListener
`LoginListener.Adapter`

Field Summary

Fields inherited from class com.antelmann.sql.SQLDatabase
`connectionCheckTimeout`

Constructor Summary
`SQLFactoryDatabase(Factory<Connection> factory)` calls this(factory, false), reconnect is enabled and the connection is only available within a transaction
`SQLFactoryDatabase(Factory<Connection> factory, boolean usePermanentConnection)` Note that the connection opened by this instance remains open (so that an inheriting class can still use that first connection that is instantiated).

Method Summary
`protected SQLTransaction` `createTransaction()` called by the constructor
`ConnectionWrapper` `getDatabaseServiceAsWrapper()`
`Factory<Connection>` `getFactory()`
`boolean` `isPermanentConnection()`
`void` `setPermanentConnection(boolean disableAutoReconnect)` if set to true, this instance behaves pretty much as if it were its superclass.

Methods inherited from class com.antelmann.sql.SQLDatabase
`close, generateGenericClassStore, generateGenericClassStore, getColumnNames, getColumnTypes, getDisplayColumn, getHelper, getIDColumn, getRandomEntry, getTableName, getTableNames, getTableQuery, getTransaction, isValid, queryStoreForInterface`

Methods inherited from class com.antelmann.db.AbstractDatabase

`addConfigListener, addStoreListener, checkAccessRight, checkTransactionActive, clearAllData, contains, contains, count, countStubs, delete, delete, delete, extractInterface, failedLogin, finalize, fireStoreChanges, getAccessController, getAvailableClassStores, getConfigListeners, getCurrentUser, getDatabaseService, getEntry, getEntry, getEntry, getFirstEntry, getFirstStub, getLogger, getOriginalClassStore, getRandomEntry, getRandomStub, getStore, getStoreForEntry, getStoreListeners, getStub, getStub, hasAutomatedTransactions, isEnsureTransactions, isVersioningEnabled, listEntries, listEntries, listStubs, loginPerformed, logoutPerformed, mapEntries, mapStubs, putClassStore, query, remove, removeConfigListener, removeStoreListener, setAccessController, setAutomatedTransactions, setCurrentUser, setEnsureTransactions, setVersioningEnabled, store`

Methods inherited from class java.lang.Object
`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SQLFactoryDatabase

    public SQLFactoryDatabase(Factory<Connection> factory)
                       throws Exception

  calls this(factory, false), reconnect is enabled and the connection is only available within a transaction

  Throws:
    `Exception`

### SQLFactoryDatabase

    public SQLFactoryDatabase(Factory<Connection> factory,
                              boolean usePermanentConnection)
                       throws Exception

  Note that the connection opened by this instance remains open (so that an inheriting class can still use that first connection that is instantiated).

  Parameters:
    `usePermanentConnection` - if true, it behaves pretty much like the super class
  Throws:
    `Exception`

Method Detail

### getFactory

    public Factory<Connection> getFactory()

### getDatabaseServiceAsWrapper

    public ConnectionWrapper getDatabaseServiceAsWrapper()

### isPermanentConnection

    public boolean isPermanentConnection()

  See Also:
    `setPermanentConnection(boolean)`

### setPermanentConnection

    public void setPermanentConnection(boolean disableAutoReconnect)
                                throws IllegalStateException,
                                       SQLException

  if set to true, this instance behaves pretty much as if it were its superclass. If false, the connection is only available during a transaction. The method must be called outside a transaction.

  Throws:
    `IllegalStateException` - if the method was called inside a transaction
    `SQLException` - when either closing the connection or recreating the connection fails

### createTransaction

    protected SQLTransaction createTransaction()
                                        throws SQLException

  Description copied from class: `SQLDatabase`
  called by the constructor

  Overrides:
    `createTransaction` in class `SQLDatabase`
  Throws:
    `SQLException`

(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads