Package de.xima.fc.dao.utils
Class ConnectionCreator
- java.lang.Object
-
- de.xima.fc.dao.utils.ConnectionCreator
-
- All Implemented Interfaces:
IConnectionCreator
public class ConnectionCreator extends Object implements IConnectionCreator
Creates a pooled connection to a database. A connection obtained withgetConnection()should be handled with try-with-resources.- Since:
- 8.6.0
- Author:
- Hannes John
-
-
Constructor Summary
Constructors Constructor Description ConnectionCreator(DatenbankZugriff dbConnection)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<Connection>getConnection()Opens a new connection, if available.EDatenbankTypgetDatenbankTyp()Returns the database type of the connection.intgetMaxConnections()Retrieves the number of maximum connections of the underlying connection pool.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.xima.fc.dao.interfaces.IConnectionCreator
getVorgangsDataSQLBuilder
-
-
-
-
Constructor Detail
-
ConnectionCreator
public ConnectionCreator(DatenbankZugriff dbConnection)
Constructor.- Parameters:
dbConnection- database connection entity
-
-
Method Detail
-
getConnection
public Optional<Connection> getConnection() throws FcPersistenceException, SQLException
Description copied from interface:IConnectionCreatorOpens a new connection, if available.- Specified by:
getConnectionin interfaceIConnectionCreator- Returns:
- connection, if available
- Throws:
FcPersistenceException- if no connection can be establishedSQLException- if the database cannot be accessed
-
getMaxConnections
public int getMaxConnections()
Description copied from interface:IConnectionCreatorRetrieves the number of maximum connections of the underlying connection pool. This can be used for concurrency.- Specified by:
getMaxConnectionsin interfaceIConnectionCreator- Returns:
- number of maximum connections
-
getDatenbankTyp
public EDatenbankTyp getDatenbankTyp()
Description copied from interface:IConnectionCreatorReturns the database type of the connection.- Specified by:
getDatenbankTypin interfaceIConnectionCreator- Returns:
- database type
-
-