|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.googlecode.jdbw.impl.DatabaseConnectionImpl
public class DatabaseConnectionImpl
This is a default implementation of the DatabaseConnection interface,
you can construct objects of this type with a Connection or a
DataSource.
| Constructor Summary | |
|---|---|
DatabaseConnectionImpl(Connection connection)
Creates a DatabaseConnectionImpl backed by one physical database
connection. |
|
DatabaseConnectionImpl(Connection connection,
DatabaseServerType databaseServerType)
Creates a DatabaseConnectionImpl backed by one physical database
connection. |
|
DatabaseConnectionImpl(DataSource dataSource)
Creates a DatabaseConnectionImpl backed by a DataSource. |
|
DatabaseConnectionImpl(DataSource dataSource,
DatabaseServerType databaseServerType)
Creates a DatabaseConnectionImpl backed by a DataSource. |
|
DatabaseConnectionImpl(DataSource dataSource,
DataSourceCloser dataSourceCloser)
Creates a DatabaseConnectionImpl backed by a DataSource. |
|
DatabaseConnectionImpl(DataSource dataSource,
DataSourceCloser dataSourceCloser,
DatabaseServerType databaseServerType)
Creates a DatabaseConnectionImpl backed by a DataSource. |
|
| Method Summary | |
|---|---|
DatabaseTransaction |
beginTransaction(TransactionIsolation transactionIsolation)
Allocated a connection and begins a transaction |
void |
close()
Closes this connection and any underlying data source |
AutoExecutor |
createAutoExecutor()
Creates an AutoExecutor using this database connection for supplying connections |
protected MetaDataResolver |
createMetaDataResolver()
|
Catalog |
getCatalog(String catalogName)
Looks up one catalog on the server |
List<Catalog> |
getCatalogs()
|
String |
getDefaultCatalogName()
|
TransactionIsolation |
getDefaultTransactionIsolation()
|
DatabaseServerType |
getServerType()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DatabaseConnectionImpl(Connection connection)
DatabaseConnectionImpl backed by one physical database
connection. Since there is only one connection, you can only have one
ongoing operation against the database at one time. Trying to operate on
the database with multiple threads will serialize to one thread accessing
the database at a time through blocking. An active transaction counts as
an ongoing operation; failing to properly close it (by committing or
rolling back) may leave the DatabaseConnectionImpl unusable with
some method calls blocking indefinitely.
The type of the database server will be guessed, but you can also be
helpful and call the overloaded constructor which takes a
Connection and a DatabaseServerType to specify what you
are connecting to.
connection - Connection that is backing this DatabaseConnection
IllegalArgumentException - If the database server type could not be
figured out
public DatabaseConnectionImpl(Connection connection,
DatabaseServerType databaseServerType)
DatabaseConnectionImpl backed by one physical database
connection. Since there is only one connection, you can only have one
ongoing operation against the database at one time. Trying to operate on
the database with multiple threads will serialize to one thread accessing
the database at a time through blocking. An active transaction counts as
an ongoing operation; failing to properly close it (by committing or
rolling back) may leave the DatabaseConnectionImpl unusable with
some method calls blocking indefinitely.
connection - Connection that is backing this DatabaseConnectiondatabaseServerType - Type of the database serverpublic DatabaseConnectionImpl(DataSource dataSource)
DatabaseConnectionImpl backed by a DataSource.
The behavior of the constructed DatabaseConnectionImpl is very
much determined by what kind of DataSource you are passing in as
the first parameter. Typically, this will be a connection pool and as
such you will be able to operated on this DatabaseConnectionImpl
with multiple threads in parallel. Normally, if the pool is starved and
cannot allocate any more connection, it will block until a connection
is available. In this case, the DatabaseConnectionImpl will block
too, when calling the methods that utilize the database connection. If
the DataSource throws an exception when no more connections can
be allocated, so will the DatabaseConnectionImpl.
Please note that a DataSource doesn't expose any method for
closing it, so calling close() on this
DatabaseConnectionImpl won't do anything. If you want to be able
to close the underlying source through this object, please use one of the
constructor overloads with a DataSourceCloser parameter.
The type of the database server will be guessed, but you can also be
helpful and call an overloaded constructor which takes a
DatabaseServerType to specify what you are connecting to.
dataSource - Underlying database connection supplier
IllegalArgumentException - If the database server type could not be
figured out
public DatabaseConnectionImpl(DataSource dataSource,
DatabaseServerType databaseServerType)
DatabaseConnectionImpl backed by a DataSource.
The behavior of the constructed DatabaseConnectionImpl is very
much determined by what kind of DataSource you are passing in as
the first parameter. Typically, this will be a connection pool and as
such you will be able to operated on this DatabaseConnectionImpl
with multiple threads in parallel. Normally, if the pool is starved and
cannot allocate any more connection, it will block until a connection
is available. In this case, the DatabaseConnectionImpl will block
too, when calling the methods that utilize the database connection. If
the DataSource throws an exception when no more connections can
be allocated, so will the DatabaseConnectionImpl.
Please note that a DataSource doesn't expose any method for
closing it, so calling close() on this
DatabaseConnectionImpl won't do anything. If you want to be able
to close the underlying source through this object, please use one of the
constructor overloads with a DataSourceCloser parameter.
dataSource - Underlying database connection supplierdatabaseServerType - Type of the database server
public DatabaseConnectionImpl(DataSource dataSource,
DataSourceCloser dataSourceCloser)
DatabaseConnectionImpl backed by a DataSource.
The behavior of the constructed DatabaseConnectionImpl is very
much determined by what kind of DataSource you are passing in as
the first parameter. Typically, this will be a connection pool and as
such you will be able to operated on this DatabaseConnectionImpl
with multiple threads in parallel. Normally, if the pool is starved and
cannot allocate any more connection, it will block until a connection
is available. In this case, the DatabaseConnectionImpl will block
too, when calling the methods that utilize the database connection. If
the DataSource throws an exception when no more connections can
be allocated, so will the DatabaseConnectionImpl.
Please note that a DataSource doesn't expose any method for
closing it, that why this constructor takes a DataSourceCloser
interface as a parameter. It is assumed the closer knows how to close
this particular DataSource. If you don't need to close the
DataSource (through this DatabaseConnectionImpl), you can
pass null for this parameter.
The type of the database server will be guessed, but you can also be
helpful and call the overloaded constructor which takes a
DataSource, a DataSourceCloser and a
DatabaseServerType to specify what you are connecting to.
dataSource - Underlying database connection supplierdataSourceCloser - Object which knows how to close the data source,
or null if you want calls to close() be ignored
IllegalArgumentException - If the database server type could not be
figured out
public DatabaseConnectionImpl(DataSource dataSource,
DataSourceCloser dataSourceCloser,
DatabaseServerType databaseServerType)
DatabaseConnectionImpl backed by a DataSource.
The behavior of the constructed DatabaseConnectionImpl is very
much determined by what kind of DataSource you are passing in as
the first parameter. Typically, this will be a connection pool and as
such you will be able to operated on this DatabaseConnectionImpl
with multiple threads in parallel. Normally, if the pool is starved and
cannot allocate any more connection, it will block until a connection
is available. In this case, the DatabaseConnectionImpl will block
too, when calling the methods that utilize the database connection. If
the DataSource throws an exception when no more connections can
be allocated, so will the DatabaseConnectionImpl.
Please note that a DataSource doesn't expose any method for
closing it, that why this constructor takes a DataSourceCloser
interface as a parameter. It is assumed the closer knows how to close
this particular DataSource. If you don't need to close the
DataSource (through this DatabaseConnectionImpl), you can
pass null for this parameter.
dataSource - Underlying database connection supplierdataSourceCloser - Object which knows how to close the data source,
or null if you want calls to close() be ignoreddatabaseServerType - Type of the database server| Method Detail |
|---|
public TransactionIsolation getDefaultTransactionIsolation()
getDefaultTransactionIsolation in interface DatabaseConnectionpublic void close()
DatabaseConnection
close in interface DatabaseConnection
public DatabaseTransaction beginTransaction(TransactionIsolation transactionIsolation)
throws SQLException
DatabaseConnection
beginTransaction in interface DatabaseConnectiontransactionIsolation - Isolation level for the new transaction
SQLException - If an error occurred when allocating a connection
for this transactionpublic AutoExecutor createAutoExecutor()
DatabaseConnection
createAutoExecutor in interface DatabaseConnection
public List<Catalog> getCatalogs()
throws SQLException
getCatalogs in interface DatabaseConnectionSQLException - If an error occurred when asking the database
for catalog information
public Catalog getCatalog(String catalogName)
throws SQLException
DatabaseConnection
getCatalog in interface DatabaseConnectioncatalogName - Name of the catalog
SQLException - If an error occurred when asking the database
for catalog informationpublic DatabaseServerType getServerType()
getServerType in interface DatabaseConnectionpublic String getDefaultCatalogName()
getDefaultCatalogName in interface DatabaseConnectionprotected MetaDataResolver createMetaDataResolver()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||