Skip to content

Instantly share code, notes, and snippets.

@Inkimar
Last active December 20, 2023 09:28
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Inkimar/6ca3014fef4abfd02025 to your computer and use it in GitHub Desktop.
Save Inkimar/6ca3014fef4abfd02025 to your computer and use it in GitHub Desktop.
jboss-cli setting a datasource
Testing with 5.1.38 ( mysql-connector-java-5.1.38-bin.jar 5.1.38 )
~log in to admin~
$./bin/jboss-cli.sh --connect
~before you start, take a snapshot of the configuration :~
~snapshot is saved in -> /wildfly/standalone/configuration/standalone_xml_history/snapshot~
[domain@localhost:9999 /] :take-snapshot()
~mysql-connector-java-5.1.38 ~
[domain@localhost:9999 /] )
deploy ~/<location-directory>/mysql-connector-java-5.1.38-bin.jar
~remove your old connection, ex NaturDS ~
[domain@localhost:9999 /] data-source --name=NaturDS disable
[domain@localhost:9999 /] /:reload
[domain@localhost:9999 /] data-source --name=NaturDS remove
~Add the new connection, ex NaturDS ~
[domain@localhost:9999 /] data-source add --name=NaturDS --jndi-name=java:/NaturDS --driver-name=mysql-connector-java-5.1.38-bin.jar_com.mysql.jdbc.Driver_5_1 --connection-url=jdbc:mysql://localhost:3306/taxonpages_v2 \
--user-name=root --password=boho \
--check-valid-connection-sql="SELECT 1" \
--background-validation=true \
--background-validation-millis=60000 \
--flush-strategy=IdleConnections \
--min-pool-size=10 --max-pool-size=50 --pool-prefill=false
The out put is in standalone.xml ( cat standalone.xml)
<datasource jndi-name="java:/NaturDS" pool-name="NaturDS" enabled="true">
<connection-url>jdbc:mysql://localhost:3306/taxonpages_v2</connection-url>
<driver>mysql-connector-java-5.1.38-bin.jar_com.mysql.jdbc.Driver_5_1</driver>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>50</max-pool-size>
<prefill>false</prefill>
<flush-strategy>IdleConnections</flush-strategy>
</pool>
<security>
<user-name>root</user-name>
<password>boho</password>
</security>
<validation>
<check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
<background-validation>true</background-validation>
<background-validation-millis>60000</background-validation-millis>
</validation>
</datasource>
check Information:
5) /subsystem=datasources/data-source=NaturDS:read-resource(include-runtime=true,recursive=true)
ping your data-source
6) /subsystem=datasources/data-source=NaturDS:test-connection-in-pool
7) data-source flush-all-connection-in-pool --name=NaturDS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment