This article discusses the causes and the solution for the error “SQLException: This connection has been closed“. that can happen when using a Java Connection to the Database that is no longer active.
WildFly Datasource configuration
A javax.sql.DataSource objects simplifies access to a Database by implementing classes that allow you to use connection pool.
In WildFly, the DataSource object is available in all server configurations through the datasources subsystem. Out of the box, an H2 Datasource is available for testing purposes.
You can learn more about DataSource Configuration through the following resources:
DataSource set up
How to set up a Datasource with WildFly
How to configure the DataSource Connection pool
Configuring Agroal Datasource on WildFly
Creating a Datasource using a CLI script
Creating a Datasource using the Web Console
Hardening a DataSource
How to validate Database connections in JBoss / WildFly
How to encrypt the Datasource password
Monitoring / Troubleshooting
How to trace JDBC statements with JBoss and WildFly
Solving “No managed connections available within configured blocking timeout”
Using try-with-resources to close database connections
DataSource and Enterprise applications
How to deploy a DataSource in jboss at application level
How to inject a DataSource in your Enterprise applications
Advanced topics
Configuring Datasource JTA and XA settings
How do I access the specific driver Connection with JBoss
Database specific tutorials
Configuring a PostgreSQL DataSource
Configuring MS SQLServer DataSource
Configuring a MySQL DataSource
How to create a Datasource with JBoss / WildFly
This article will teach you how to create and configure a DataSource with WildFly application server using the Command Line Interface tool. At the end of this article, we will show how to inject and use the Datasource in a sample Java application.
Configuring a datasource with PostgreSQL and JBoss/WildFly
This tech tip shows how you can install and configure PostgreSQL with JBoss / WildFly going into the details of PostGreSQL installation, configuration and tuning. We will also learn how to configure hibernate postgresql dialect in a JPA application. Installing PostgreSQL We will assume that you are running on a Linux machine. Firstly, install PostgreSQL: Next, … Read more
Using try-with-resources to close database connections
Managing database connections is a crucial aspect of Java programming, especially when working with relational databases. Java provides a convenient way to handle resources, including database connections, using the try-with-resources statement introduced in Java 7. This feature simplifies resource management by automatically closing resources when they are no longer needed, reducing the risk of resource … Read more
Configuring a Datasource with MySQL on WildFly
In this tutorial we will learn how to install and configure a Datasource on WildFly which uses MySQL or MariaDB as Database. We will show how to set up MySQL database using Docker. Then, we will show the Datasource configuration in both standalone mode and domain mode. Step 1: Set up MySQL Database In order to … Read more
allowPublicKeyRetrieval option in the MySQL JDBC connector
The allowPublicKeyRetrieval
option in the MySQL JDBC connector is used to control whether the client is allowed to request the public key of the server during an SSL connection. By default, this option is set to false
to enhance security and prevent potential man-in-the-middle attacks. However, in some cases, it may be necessary to set this option to true
to enable certain features or compatibility with older applications.
How to connect to PostgreSQL from Java over SSL
Configuring JDBC connectivity to PostgreSQL over SSL involves a few steps, especially when setting up SSL validation or opting for a non-validating SSL connection. Below is a tutorial demonstrating both options.
How to solve the issue JDBCConnectionException: could not extract ResultSet
The JDBCConnectionException with the message “could not extract ResultSet” is a common exception encountered in Java applications that interact with databases. This article aims to explore the possible root causes of this exception and provide troubleshooting steps to help you resolve the issue. Root Causes of JDBCConnectionException: Could Not Extract ResultSet Troubleshooting Steps Conclusion The … Read more
WildFly Connection Pool configuration made easy
WildFly uses a pool of Database Connection objects to your applications. A Connection Pool is a way to reduce the cost of opening and closing Database connections by maintaining a Pool of Database connections. In this article we will learn how to configure WildFly Connection Pool in an optimal way.
H2 Database Tutorial and expert Tips
H2 DB is an open source lightweight Database written in Java. It ships in JBoss EAP and WildFly application server to speed up developing and testing Java applications. Let’s have a look to the main configuration options and how to create an example application using the H2 DB. What is H2 database? Firstly, let’s see … Read more