Book Image

Wildfly Cookbook

Book Image

Wildfly Cookbook

Overview of this book

Table of Contents (23 chapters)
WildFly Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Checking the datasource connection


Sometimes, you might see errors in your log's application because of something going wrong with your persistence storage. The first thing to do in that case, is to check if the database is up and running by testing its connection; you may even realize that you are pointing to a wrong one or you misspelled the connection URL.

Getting ready

This recipe is based on the previous one, where we have configured a datasource which connects to a local MySQL database, so we will test our database connection with the WildFlyCookBookDS datasource. You can test the connection with a datasource of your choice as long as you provide the correct configuration as well.

How to do it...

  1. With a running WildFly server, open your command-line tool and connect to the CLI:

    $ ./bin/jboss-cli.sh --connect
    [standalone@localhost:9990 /]
  2. Now execute the following commands:

    [standalone@localhost:9990 /] /subsystem=datasources/data-source=WildFlyCookbookDS:test-connection-in-pool()
    {
        "outcome...