|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.db.AbstractDatabase<Connection>
com.antelmann.sql.SQLDatabase
public class SQLDatabase
implements a database using a SQLTransaction instance based on a JDBC connection. The given Connection will be set to disable autoCommit.
SQLTransaction| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.antelmann.db.LoginListener |
|---|
LoginListener.Adapter |
| Field Summary | |
|---|---|
protected int |
connectionCheckTimeout
|
| Constructor Summary | |
|---|---|
SQLDatabase(Connection con)
|
|
SQLDatabase(Connection con,
User user,
LogWriter logWriter)
the logWriter remains unchecked regarding access during a non-active transaction |
|
| Method Summary | ||
|---|---|---|
void |
close()
|
|
protected DBTransaction |
createTransaction()
called by the constructor |
|
DBClassStore<RowItem> |
generateGenericClassStore(String table,
String idColumn)
generates and returns a generic wrapped DBClassStore on RowItem objects; the store is not put into the database. |
|
GenericPropertyEntryStore<RowItem> |
generateGenericClassStore(String table,
String idColumn,
String displayColumn)
generates and returns a generic wrapped DBClassStore on RowItem objects; the store is not put into the database (as multiple stores working on different tables could map to the RowItem class). |
|
String[] |
getColumnNames(Class<? extends DBEntry> type)
returns all column names that are mapped by the standard query by taking advantage of the MappingInfo interface - if applicable |
|
Hashtable<String,Integer> |
getColumnTypes(Class<? extends DBEntry> type)
returns all column names mapped to their respective Types. |
|
String |
getDisplayColumn(Class<? extends DBEntry> type)
takes advantage of the MappingInfo interface - if applicable |
|
protected ConnectionHelper |
getHelper()
|
|
String |
getIDColumn(Class<? extends DBEntry> type)
takes advantage of the MappingInfo interface - if applicable |
|
|
getRandomEntry(Class<T> type,
Filter<? super T> filter)
|
|
String |
getTableName(Class<? extends DBEntry> type)
takes advantage of the MappingInfo interface - if applicable |
|
String[] |
getTableNames()
|
|
String |
getTableQuery(Class<? extends DBEntry> type)
takes advantage of the MappingInfo interface - if applicable |
|
DBTransaction |
getTransaction()
provides access to the DBTransaction, which coordinates all access to the Resources via DBClassStore. |
|
protected boolean |
isValid(Connection con)
by overwriting this method you can customize the way a connection is checked for being valid by overwriting this method (note that this default implementation is not supported by the Sun JDBC/ODBC bridge). |
|
|
queryStoreForInterface(Class<E> type,
Class<I> desiredInterface)
additionally supports SQLColumnInfo via SQLColumnInfoStore
for every store supporting MappingInfo |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int connectionCheckTimeout
| Constructor Detail |
|---|
public SQLDatabase(Connection con)
throws SQLException
SQLException
public SQLDatabase(Connection con,
User user,
LogWriter logWriter)
throws SQLException
SQLException| Method Detail |
|---|
protected DBTransaction createTransaction()
throws SQLException
SQLExceptionprotected final ConnectionHelper getHelper()
public DBTransaction getTransaction()
Database
public void close()
throws IOException
close in interface Closeableclose in class AbstractDatabase<Connection>IOException
protected boolean isValid(Connection con)
throws SQLException
SQLExceptionConnection.isValid(int),
connectionCheckTimeout
public DBClassStore<RowItem> generateGenericClassStore(String table,
String idColumn)
throws DatabaseException
DatabaseExceptionGenericPropertyEntryStore,
DBClassStoreWrapper
@Warning(value="NOTE THAT CALLS ON THE INTERFACE STILL NEED TO BE SYNCHRONIZED WITH THE TRANSACTION!")
@Todo(value="support inserts with an idFactory")
public GenericPropertyEntryStore<RowItem> generateGenericClassStore(String table,
String idColumn,
String displayColumn)
throws DatabaseException
DatabaseExceptionDBUtils.wrapTransactional(com.antelmann.db.DBTransaction, Object, Class),
GenericPropertyEntryStore
public String[] getTableNames()
throws DatabaseException
DatabaseExceptionpublic String getTableName(Class<? extends DBEntry> type)
MappingInfo interface - if applicable
public String getIDColumn(Class<? extends DBEntry> type)
MappingInfo interface - if applicable
public String getTableQuery(Class<? extends DBEntry> type)
MappingInfo interface - if applicable
public String getDisplayColumn(Class<? extends DBEntry> type)
MappingInfo interface - if applicable
public String[] getColumnNames(Class<? extends DBEntry> type)
throws DatabaseException
MappingInfo interface - if applicable
DatabaseException
public Hashtable<String,Integer> getColumnTypes(Class<? extends DBEntry> type)
throws DatabaseException
Types.
of the MappingInfo interface - if applicable
DatabaseException
public <E extends DBEntry,I> I queryStoreForInterface(Class<E> type,
Class<I> desiredInterface)
SQLColumnInfo via SQLColumnInfoStore
for every store supporting MappingInfo
queryStoreForInterface in interface Database<Connection>queryStoreForInterface in class AbstractDatabase<Connection>type - the DBEntry-type of the DBClassStore that is to implement the desired interfacedesiredInterface - the class of the interface that the store is implementing
WrappedDBClassStore.exposesInterfaces()
@Warning(value="only works properly for classes that are represented by a JDBCRowStore, since it supports an OffsetFilter in the reqired way")
public <T extends DBEntry> T getRandomEntry(Class<T> type,
Filter<? super T> filter)
throws DatabaseException
getRandomEntry in class AbstractDatabase<Connection>DatabaseException
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||