Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying WildFly Configuration, Deployment, and Administration - Second Edition
  • Table Of Contents Toc
WildFly Configuration, Deployment, and Administration - Second Edition

WildFly Configuration, Deployment, and Administration - Second Edition - Second Edition

4.4 (5)
close
close
WildFly Configuration, Deployment, and Administration - Second Edition

WildFly Configuration, Deployment, and Administration - Second Edition

4.4 (5)

Overview of this book

This book is aimed at Java developers, system administrators, application testers using WildFly, and anyone who performs a DevOps role. Whether you are completely new to WildFly or just require an understanding of WildFly's new features, this book is for you.
Table of Contents (14 chapters)
close
close
13
Index

Connecting to a database

To allow your application to connect to a database, you will need to configure your server by adding a datasource. Upon server startup, each datasource is prepopulated with a pool of database connections. Applications acquire a database connection from the pool by doing a JNDI lookup and then calling getConnection(). Take a look at the following code:

Connection result = null;
try {
    Context initialContext = new InitialContext();
    DataSource datasource = (DataSource)initialContext.lookup("java:/MySqlDS");
    result = datasource.getConnection();
} catch (Exception ex) {
    log("Cannot get connection: " + ex);}

After the connection has been used, you should always call connection.close() as soon as possible. This frees the connection and allows it to be returned to the connection pool—ready for other applications or processes to use.

Releases prior to JBoss AS 7 required a datasource configuration file (ds.xml) to be deployed with...

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
WildFly Configuration, Deployment, and Administration - Second Edition
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon