Class BibernateDataSource
java.lang.Object
io.github.blyznytsiaorg.bibernate.connectionpool.BibernateDataSource
- All Implemented Interfaces:
Wrapper
,CommonDataSource
,DataSource
- Direct Known Subclasses:
TransactionalDatasource
BibernateDataSource is an implementation of the DataSource interface that provides connections to a database.
It manages a connection pool and allows clients to obtain connections and release them when done.
- Since:
- 1.0
- Author:
- Blyzhnytsia Team
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprivate final Queue
<Connection> The connection pool that manages connections to the database.static final String
-
Constructor Summary
ConstructorDescriptionConstructs a new BibernateDataSource with the given configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes all connections in the connection pool.Retrieves a Connection wrapped by ProxyConnection from the connection pool.getConnection
(String username, String password) int
boolean
isWrapperFor
(Class<?> iface) void
setLoginTimeout
(int seconds) void
setLogWriter
(PrintWriter out) <T> T
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilder
Methods inherited from interface javax.sql.DataSource
createConnectionBuilder
-
Field Details
-
METHOD_IS_NOT_SUPPORTED
- See Also:
-
connectionPool
The connection pool that manages connections to the database.
-
-
Constructor Details
-
BibernateDataSource
Constructs a new BibernateDataSource with the given configuration.- Parameters:
config
- the configuration for this data source- Throws:
BibernateDataSourceException
- if an error occurs while creating connections
-
-
Method Details
-
close
public void close()Closes all connections in the connection pool.- Throws:
ConnectionPoolException
- if an error occurs while closing connections
-
getConnection
Retrieves a Connection wrapped by ProxyConnection from the connection pool.- Specified by:
getConnection
in interfaceDataSource
- Returns:
- a Connection object from the connection pool
- Throws:
SQLException
- if a database access error occurs
-
getConnection
- Specified by:
getConnection
in interfaceDataSource
- Throws:
SQLException
-
getLogWriter
- Specified by:
getLogWriter
in interfaceCommonDataSource
- Specified by:
getLogWriter
in interfaceDataSource
-
setLogWriter
- Specified by:
setLogWriter
in interfaceCommonDataSource
- Specified by:
setLogWriter
in interfaceDataSource
-
setLoginTimeout
public void setLoginTimeout(int seconds) - Specified by:
setLoginTimeout
in interfaceCommonDataSource
- Specified by:
setLoginTimeout
in interfaceDataSource
-
getLoginTimeout
public int getLoginTimeout()- Specified by:
getLoginTimeout
in interfaceCommonDataSource
- Specified by:
getLoginTimeout
in interfaceDataSource
-
getParentLogger
- Specified by:
getParentLogger
in interfaceCommonDataSource
-
unwrap
-
isWrapperFor
- Specified by:
isWrapperFor
in interfaceWrapper
-