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
FieldsModifier and TypeFieldDescriptionprivate final Queue<Connection> The connection pool that manages connections to the database.static final String -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new BibernateDataSource with the given configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes all connections in the connection pool.Retrieves a Connection wrapped by ProxyConnection from the connection pool.getConnection(String username, String password) intbooleanisWrapperFor(Class<?> iface) voidsetLoginTimeout(int seconds) voidsetLogWriter(PrintWriter out) <T> TMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilderMethods 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:
getConnectionin interfaceDataSource- Returns:
- a Connection object from the connection pool
- Throws:
SQLException- if a database access error occurs
-
getConnection
- Specified by:
getConnectionin interfaceDataSource- Throws:
SQLException
-
getLogWriter
- Specified by:
getLogWriterin interfaceCommonDataSource- Specified by:
getLogWriterin interfaceDataSource
-
setLogWriter
- Specified by:
setLogWriterin interfaceCommonDataSource- Specified by:
setLogWriterin interfaceDataSource
-
setLoginTimeout
public void setLoginTimeout(int seconds) - Specified by:
setLoginTimeoutin interfaceCommonDataSource- Specified by:
setLoginTimeoutin interfaceDataSource
-
getLoginTimeout
public int getLoginTimeout()- Specified by:
getLoginTimeoutin interfaceCommonDataSource- Specified by:
getLoginTimeoutin interfaceDataSource
-
getParentLogger
- Specified by:
getParentLoggerin interfaceCommonDataSource
-
unwrap
-
isWrapperFor
- Specified by:
isWrapperForin interfaceWrapper
-