2016-04-30 04:39:32 +00:00
2021-11-10 11:39:43 +00:00
=== Modifying the {project_name} datasource
2016-04-27 21:01:22 +00:00
2021-11-10 11:39:43 +00:00
You modify the existing datasource configuration that {project_name} uses
2016-04-29 16:09:09 +00:00
to connect it to your new external database. You'll do
this within the same configuration file and XML block that you registered your JDBC driver in. Here's an example
2016-12-06 20:53:48 +00:00
that sets up the connection to your new database:
2016-04-27 21:01:22 +00:00
.Declare Your JDBC Drivers
2018-06-12 20:10:27 +00:00
[source,xml,subs="attributes+"]
2016-04-27 21:01:22 +00:00
----
2018-06-12 20:10:27 +00:00
<subsystem xmlns="{subsystem_datasources_xml_urn}">
2016-04-27 21:01:22 +00:00
<datasources>
...
<datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" enabled="true" use-java-context="true">
<connection-url>jdbc:postgresql://localhost/keycloak</connection-url>
<driver>postgresql</driver>
<pool>
<max-pool-size>20</max-pool-size>
</pool>
<security>
<user-name>William</user-name>
<password>password</password>
</security>
</datasource>
...
</datasources>
</subsystem>
----
2021-11-10 11:39:43 +00:00
.Prerequisites
* You have already declared your JDBC driver.
.Procedure
. Search for the `datasource` definition for `KeycloakDS`.
+
You'll first need to modify the `connection-url`. The
2016-04-29 16:09:09 +00:00
documentation for your vendor's JDBC implementation should specify the format for this connection URL value.
2016-04-27 21:01:22 +00:00
2021-11-10 11:39:43 +00:00
. Define the `driver` you will use.
+
This is the logical name of the JDBC driver you declared in the previous section of this
2016-04-27 21:01:22 +00:00
chapter.
2021-11-10 11:39:43 +00:00
+
2016-09-27 15:29:45 +00:00
It is expensive to open a new connection to a database every time you want to perform a transaction. To compensate, the datasource
2016-04-29 20:12:12 +00:00
implementation maintains a pool of open connections. The `max-pool-size` specifies the maximum number of connections it will pool.
2016-04-27 21:01:22 +00:00
You may want to change the value of this depending on the load of your system.
2021-11-10 11:39:43 +00:00
. Define the database username and password that is needed to connect to the database. This step is necessary for at least PostgreSQL. You may be concerned that these credentials are in clear text in the example. Methods exist to obfuscate these credentials, but these methods are beyond the scope of this guide.
2016-04-27 21:01:22 +00:00
2017-08-28 12:50:14 +00:00
NOTE: For more information about datasource features, see link:{appserver_datasource_link}[the datasource configuration chapter] in the _{appserver_admindoc_name}_.