Este conteúdo não está disponível no idioma selecionado.
Chapter 11. Adding managed datasources to Data Grid Server
Optimize connection pooling and performance for JDBC database connections by adding managed datasources to your Data Grid Server configuration.
11.1. Configuring managed datasources Copiar o linkLink copiado para a área de transferência!
Create managed datasources as part of your Data Grid Server configuration to optimize connection pooling and performance for JDBC database connections. You can then specify the JDNI name of the managed datasources in your caches, which centralizes JDBC connection configuration for your deployment.
Prerequisites
Copy database drivers to the
server/libdirectory in your Data Grid Server installation.TipUse the
installcommand with the Data Grid Command Line Interface (CLI) to download the required drivers to theserver/libdirectory, for example:install org.postgresql:postgresql:42.4.3
install org.postgresql:postgresql:42.4.3Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure
- Open your Data Grid Server configuration for editing.
-
Add a new
data-sourceto thedata-sourcessection. -
Uniquely identify the datasource with the
nameattribute or field. Specify a JNDI name for the datasource with the
jndi-nameattribute or field.TipYou use the JNDI name to specify the datasource in your JDBC cache store configuration.
-
Set
trueas the value of thestatisticsattribute or field to enable statistics for the datasource through the/metricsendpoint. Provide JDBC driver details that define how to connect to the datasource in the
connection-factorysection.-
Specify the name of the database driver with the
driverattribute or field. -
Specify the JDBC connection url with the
urlattribute or field. -
Specify credentials with the
usernameandpasswordattributes or fields. - Provide any other configuration as appropriate.
-
Specify the name of the database driver with the
-
Define how Data Grid Server nodes pool and reuse connections with connection pool tuning properties in the
connection-poolsection. - Save the changes to your configuration.
Verification
Use the Data Grid Command Line Interface (CLI) to test the datasource connection, as follows:
Start a CLI session.
bin/cli.sh
bin/cli.shCopy to Clipboard Copied! Toggle word wrap Toggle overflow List all datasources and confirm the one you created is available.
server datasource ls
server datasource lsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Test a datasource connection.
server datasource test my-datasource
server datasource test my-datasourceCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Managed datasource configuration
XML
JSON
YAML
11.2. Configuring caches with JNDI names Copiar o linkLink copiado para a área de transferência!
When you add a managed datasource to Data Grid Server you can add the JNDI name to a JDBC-based cache store configuration.
Prerequisites
- Configure Data Grid Server with a managed datasource.
Procedure
- Open your cache configuration for editing.
-
Add the
data-sourceelement or field to the JDBC-based cache store configuration. -
Specify the JNDI name of the managed datasource as the value of the
jndi-urlattribute. - Configure the JDBC-based cache stores as appropriate.
- Save the changes to your configuration.
JNDI name in cache configuration
XML
JSON
YAML
11.3. Connection pool tuning properties Copiar o linkLink copiado para a área de transferência!
You can tune JDBC connection pools for managed datasources in your Data Grid Server configuration.
| Property | Description |
|---|---|
|
| Initial number of connections the pool should hold. |
|
| Maximum number of connections in the pool. |
|
| Minimum number of connections the pool should hold. |
|
|
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 |
|
|
Time in milliseconds between background validation runs. A duration of |
|
|
Connections idle for longer than this time, specified in milliseconds, are validated before being acquired (foreground validation). A duration of |
|
| Time in minutes a connection has to be idle before it can be removed. |
|
| Time in milliseconds a connection has to be held before a leak warning. |