이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 12. Configuring Data Grid Server Datasources
Create managed datasources to optimize connection pooling and performance for database connections.
You can specify database connection properties as part of a JDBC cache store configuration. However, you must do this for each cache definition, which duplicates configuration and wastes resources by creating multiple distinct connection pools.
By using shared, managed datasources, you centralize connection configuration and pooling for more efficient usage.
12.1. Datasource Configuration for JDBC Cache Stores 링크 복사링크가 클립보드에 복사되었습니다!
Data Grid server configuration for datasources is composed of two sections:
-
A
connection factory
that defines how to connect to the database. -
A
connection pool
that defines how to pool and reuse connections.
Connection pools can be tuned using the following parameters:
-
initial-size
: Initial number of connections the pool should hold. -
max-size
: Maximum number of connections in the pool. -
min-size
: Minimum number of connections the pool should hold. -
blocking-timeout
: Maximum time in milliseconds to block while waiting for a connection before throwing an exception. This will never throw an exception if creating a new connection takes an inordinately long period of time. Default is 0 meaning that a call will wait indefinitely. -
background-validation
: Time in milliseconds between background validation runs. A duration of 0 means that this feature is disabled. -
validate-on-acquisition
: Connections idle for longer than this time, specified in milliseconds, are validated before being acquired (foreground validation). A duration of 0 means that this feature is disabled. -
idle-removal
: Time in minutes a connection has to be idle before it can be removed. -
leak-detection
: Time in milliseconds a connection has to be held before a leak warning.
12.2. Using Datasources in JDBC Cache Stores 링크 복사링크가 클립보드에 복사되었습니다!
Use a shared, managed datasource in your JDBC cache store configuration instead of specifying individual connection properties for each cache definition.
Prerequisites
Create a managed datasource for JDBC cache stores in your Data Grid server configuration.
Procedure
- Reference the JNDI name of the datasource in the JDBC cache store configuration of your cache configuration, as in the following example:
12.3. Testing Data Sources 링크 복사링크가 클립보드에 복사되었습니다!
Verify that connections to data sources are functioning correctly with the CLI.
Procedure
Start the CLI.
bin/cli.sh
$ bin/cli.sh [disconnected]>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow List all data sources:
[//containers/default]> server datasource ls
[//containers/default]> server datasource ls
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Test a data source connection.
[//containers/default]> server datasource test my-datasource
[//containers/default]> server datasource test my-datasource
Copy to Clipboard Copied! Toggle word wrap Toggle overflow