Package org.opencms.db
Class CmsDbPoolV11
java.lang.Object
org.opencms.db.CmsDbPoolV11
Database connection pool class using HikariCP.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Key for number of connection attempts.static final String
Key for connection waiting.static final String
Prefix for database keys.static final String
Key for the database name.static final String
Key for the pool id.static final String
Key for the entity manager pool size.static final String
Key for jdbc driver.static final String
Key for jdbc url.static final String
Key for jdbc url params.static final String
Key for database password.static final String
Key for default.static final String
Key for pool url.static final String
Key for pool user.static final String
Key for vfs pool.static final String
Key for user name.static final String
The name of the opencms default pool.static final String
The default OpenCms JDBC pool URL.static final String
The prefix used for opencms JDBC pools. -
Constructor Summary
ConstructorDescriptionCmsDbPoolV11
(CmsParameterConfiguration config, String key) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the pool.static com.zaxxer.hikari.HikariConfig
createHikariConfig
(CmsParameterConfiguration config, String key) Creates the HikariCP configuration based on the configuration of a pool defined in opencms.properties.int
Returns the number of active connections.Gets a database connection from the pool.static String
Returns the name of the default database connection pool.int
Gets the number of idle connections.Gets the pool url.static String
getPropertyRelativeSuffix
(String prefix, String str) If str starts with prefix + '.', return the remaining part, otherwise return null.
-
Field Details
-
KEY_DATABASE
Prefix for database keys.- See Also:
-
KEY_DATABASE_NAME
Key for the database name.- See Also:
-
KEY_DATABASE_POOL
Key for the pool id.- See Also:
-
KEY_CONNECT_ATTEMTS
Key for number of connection attempts.- See Also:
-
KEY_CONNECT_WAITS
Key for connection waiting.- See Also:
-
KEY_ENTITY_MANAGER_POOL_SIZE
Key for the entity manager pool size.- See Also:
-
KEY_JDBC_DRIVER
Key for jdbc driver.- See Also:
-
KEY_JDBC_URL
Key for jdbc url.- See Also:
-
KEY_JDBC_URL_PARAMS
Key for jdbc url params.- See Also:
-
KEY_PASSWORD
Key for database password.- See Also:
-
KEY_POOL_DEFAULT
Key for default.- See Also:
-
KEY_POOL_URL
Key for pool url.- See Also:
-
KEY_POOL_USER
Key for pool user.- See Also:
-
KEY_POOL_VFS
Key for vfs pool.- See Also:
-
KEY_USERNAME
Key for user name.- See Also:
-
OPENCMS_DEFAULT_POOL_NAME
The name of the opencms default pool.- See Also:
-
OPENCMS_DEFAULT_POOL_URL
The default OpenCms JDBC pool URL.- See Also:
-
OPENCMS_URL_PREFIX
The prefix used for opencms JDBC pools.- See Also:
-
-
Constructor Details
-
CmsDbPoolV11
Default constructor.- Parameters:
config
- the OpenCms configuration (opencms.properties)key
- the name of the pool (without the opencms: prefix)- Throws:
Exception
- if something goes wrong
-
-
Method Details
-
createHikariConfig
public static com.zaxxer.hikari.HikariConfig createHikariConfig(CmsParameterConfiguration config, String key) Creates the HikariCP configuration based on the configuration of a pool defined in opencms.properties.- Parameters:
config
- the configuration object with the propertieskey
- the pool name (without the opencms prefix)- Returns:
- the HikariCP configuration for the pool
-
getDefaultDbPoolName
Returns the name of the default database connection pool.- Returns:
- the name of the default database connection pool
-
getPropertyRelativeSuffix
If str starts with prefix + '.', return the remaining part, otherwise return null.- Parameters:
prefix
- the prefixstr
- the string to remove the prefix from- Returns:
- str with the prefix removed, or null if it didn't start with prefix + '.'
-
close
Closes the pool.- Throws:
Exception
- if something goes wrong
-
getActiveConnections
Returns the number of active connections.- Returns:
- the number of active connections
-
getConnection
Gets a database connection from the pool.- Returns:
- the database connection
- Throws:
SQLException
- if something goes wrong
-
getIdleConnections
Gets the number of idle connections.- Returns:
- the number of idle connections
-
getPoolUrl
Gets the pool url.- Returns:
- the pool url
-