To address the error "java.lang.IllegalStateException: Cannot get a connection as the driver manager is not properly initialized," we need to ensure that the JDBC driver is correctly initialized before attempting to establish a database connection.

1. Check JDBC Driver Initialization:

Ensure that the JDBC driver for your database is properly initialized before attempting to establish a connection. This typically involves loading the JDBC driver class using `Class.forName()` or relying on a framework that handles driver initialization automatically.



2. Verify Connection Configuration:

Double-check the connection configuration, including the database URL, username, and password. Ensure that these details are correct and properly configured in your application.

3. Handle Connection Pooling:

If you're using connection pooling, make sure that the connection pool is configured and initialized correctly. Incorrect configuration or initialization of the connection pool can lead to issues with obtaining connections.

4. Review Application Lifecycle:

Check the application lifecycle to ensure that the initialization of the JDBC driver and the establishment of database connections are performed at the appropriate time, such as during application startup or when needed.

5. Investigate Dependencies and Classpath:

Ensure that all required dependencies, including the JDBC driver JAR files, are included in the application's classpath. Missing or incorrect dependencies can prevent the JDBC driver from being properly initialized.

Solution 2:

Our problem comes from the MySQL dependency. We resolved it by updating it to version 8.0.20, which successfully resolved the issue. It's worth noting that this problem might be related to the version itself. Additionally, we upgraded the package of mysql-connector-java to version 8.0.25, which also contributed to the solution.

In this case, updating both the MySQL dependency and the mysql-connector-java package to more recent versions helped us overcome the issue.