When a JSP website starts showing database connection errors, the problem is usually not the JSP page itself. In most cases, the failure happens in one of three places: the database server is unreachable, the connection settings in the application are wrong, or the hosted Java/Tomcat environment does not have the right JDBC driver or permissions. On a managed hosting account, especially when you run a private Tomcat or JVM through Plesk and My App Server, these issues are often easy to isolate once you check the connection path step by step.
Typical symptoms include “Connection refused”, “Unknown database”, “Access denied”, “Communications link failure”, or a JSP page that loads with a generic error while the application logs show a SQL exception. The exact message matters, because it tells you whether the problem is credentials, host name, port, database name, or a runtime limitation in the Java environment.
Common reasons JSP applications fail to connect to MySQL
A JSP site usually connects to MySQL through JDBC, either directly from application code or through a configured datasource. If any part of that chain is incorrect, the connection fails. The most common causes are:
- Wrong database host — for example, using
localhostwhen the database is on a different service or host. - Incorrect username or password — even a small typo will block access.
- Missing database privileges — the MySQL user may exist, but not have rights on the target database.
- Wrong JDBC URL — the connection string may contain the wrong port, database name, or parameters.
- Missing JDBC driver — the MySQL connector JAR is not installed or not visible to Tomcat.
- Database service not running — MySQL itself may be unavailable during maintenance or a service issue.
- Port blocked or not allowed — especially if the application connects to an external database host.
- Java version or driver mismatch — an older connector may not work well with the Java version selected in My App Server.
In a hosting platform with Plesk and a managed Tomcat setup, the most frequent issues are misconfigured connection details, missing driver files, and trying to use settings from a local development environment without adapting them to the hosted server.
Check the error message first
The best starting point is the exact exception in the Tomcat or application logs. In JSP hosting, the page shown in the browser is often only a summary. The real reason is usually in the server logs or the application error log.
What different MySQL errors usually mean
- Access denied for user — the username, password, or MySQL privileges are wrong.
- Unknown database — the database name is incorrect or the database has not been created.
- Communications link failure — the database host is unreachable, the port is wrong, or the service is down.
- Connection refused — the target host is reachable, but nothing is listening on that port, or access is blocked.
- No suitable driver — the MySQL JDBC driver is missing or not loaded by the application.
- Too many connections — the database has reached its connection limit, often due to leaks or poor pooling settings.
Once you identify the exact message, you can focus on the correct layer instead of guessing.
Verify the database settings used by the JSP application
Most JSP applications read database settings from a configuration file, environment variables, a datasource definition, or a properties file inside the WAR package. When the app is deployed on a hosting platform, those settings may need to be updated after upload or redeploy.
Check these values carefully
- Database host
- Database name
- Database username
- Database password
- Database port, usually 3306 for MySQL
- JDBC URL format
- Connection parameters such as SSL, timezone, or character encoding
Example of a typical MySQL JDBC URL:
jdbc:mysql://db-hostname:3306/database_name
If the application was developed on a local machine, it may still point to localhost, a local database, or a test credential set. After deployment to hosted Tomcat, those values must match the production database settings in the control panel.
Make sure the MySQL user has permission to connect
A very common hosting issue is a valid database user that does not have the right privileges for the database. In managed hosting environments, the database and user are often created separately in the control panel. Creating the database user alone is not enough.
What to confirm in Plesk or the database tool
- The database exists and is assigned to the hosting subscription or site.
- The MySQL user is linked to that database.
- The user has the required permissions, such as SELECT, INSERT, UPDATE, DELETE, and possibly CREATE or ALTER if the application needs them.
- The application is not using an outdated password stored in a configuration file.
If the database user can log in manually but the JSP application cannot, the problem is often not the account itself but the saved credentials, a wrong hostname, or a JDBC configuration mismatch.
Check the JDBC driver in Tomcat or My App Server
For JSP hosting, the application needs the correct MySQL JDBC driver. If the driver is missing, the application cannot create a connection even if all settings are correct. This is especially important when you use your own Apache Tomcat instance or a private JVM through My App Server.
Driver-related checks
- Confirm that the MySQL Connector/J JAR file is present.
- Place the driver where Tomcat can load it, typically in the application library path or server library path, depending on your setup.
- Make sure the driver version is compatible with your Java version.
- After adding the driver, restart the Java service or Tomcat service from the control panel.
If your hosting account uses a specific Java version selected in My App Server, a very old JDBC driver may fail with newer JVMs. In that case, use a connector version that supports the Java runtime you selected.
Review the My App Server and Tomcat service status
On a hosted Java platform, the application depends on the state of the service. If Tomcat is stopped, restarting, or misconfigured, the JSP site may show database errors even if the real issue is broader service instability.
What to do in the control panel
- Open the My App Server or service control area in Plesk.
- Check whether the Tomcat service is running.
- Restart the service after changing the database configuration or driver files.
- Verify that the selected Java version matches the application’s requirements.
- Confirm that the deployed application path and context are correct.
Some applications cache configuration values or JDBC resources when they start. If you update the database password or replace the driver, a restart is often required before the changes take effect.
Test the database connection outside the JSP application
If the application keeps failing, isolate the problem by testing the database connection independently. This helps determine whether the issue is in MySQL itself or in the JSP/Tomcat layer.
Useful tests
- Log in to the hosting control panel and confirm the database is present.
- Try connecting with the same user from a database management tool if available.
- Check whether another application on the same hosting account can connect successfully.
- Look at the MySQL error log or service status if available through the hosting platform.
If the connection works outside the JSP app, the problem is likely in the application's configuration, driver loading, or datasource definition. If it fails everywhere, the issue is more likely to be at the database or account level.
Check for localhost versus remote host confusion
One of the most common migration problems is using the wrong host name for MySQL. In development, localhost often works because the database is installed on the same machine. In hosted environments, the database may be a separate service or must be accessed using a specific internal host name defined by the hosting provider.
When to suspect a host mismatch
- The application works on your local machine but fails after upload.
- The error mentions connection timeout or refused connection.
- The database credentials are correct, but the app still cannot connect.
- The control panel shows a different server name or database endpoint than the one used in the app.
Always compare the database host in the application configuration with the host shown in your hosting panel. Do not assume localhost is correct just because it worked during testing.
Look for connection pool issues
Many JSP applications use a connection pool to improve performance. If the pool settings are wrong, the site can show connection errors even when the database is healthy. This may happen if the maximum number of connections is too low, idle connections are not refreshed, or stale connections are reused.
Connection pool symptoms
- Errors appear only under load.
- The site works after restart but fails later.
- Database errors appear intermittently.
- Logs mention pool exhaustion, timeouts, or stale connections.
If your application uses a datasource in Tomcat, review the pool settings and confirm they are appropriate for a small or medium hosted application. On shared hosting or private JVM hosting, simple and stable pool settings are usually better than aggressive tuning.
Confirm the database server is reachable from the hosting environment
If your JSP application connects to an external database host, network access becomes part of the problem. Firewalls, IP restrictions, DNS problems, or incorrect ports can block the connection before Java even reaches MySQL.
Things to verify
- The database host resolves correctly from the server.
- The MySQL port is open and listening.
- The remote database allows connections from the hosting server’s IP address.
- No firewall rule blocks outgoing database traffic.
For applications hosted inside the same managed platform, this is less common, but it still matters if the database is external or the app is configured to use a remote service.
Check SSL, character set, and timezone parameters
Sometimes the database connection opens, but the application still throws errors because the JDBC connection string contains incompatible parameters. This is more likely when migrating from another host or upgrading Java.
Parameters that can affect connection stability
- useSSL and related SSL options
- serverTimezone
- characterEncoding
- allowPublicKeyRetrieval in environments that require it
These settings should match the environment and the version of the MySQL connector being used. If your application shows warnings or connection exceptions after a migration, compare the old and new JDBC URLs carefully.
Step-by-step troubleshooting checklist
Use this practical checklist when a JSP website shows database connection errors on a hosted Java setup:
- Read the exact error message in the application or Tomcat logs.
- Confirm the database name, username, and password in the app configuration.
- Verify that the MySQL user is linked to the correct database and has permissions.
- Check the database host and port in the JDBC URL.
- Make sure the MySQL Connector/J driver is installed and readable by Tomcat.
- Restart the My App Server or Tomcat service after any change.
- Test whether the database itself is reachable outside the application.
- Review connection pool settings if the error appears under load or after some time.
- Check for Java version and connector compatibility.
- Confirm that any remote database allows traffic from the hosting environment.
This order works well because it starts with the most common and easiest-to-fix causes before moving to service and network checks.
Example of a simple diagnostic approach
If your JSP page returns a database error, you can narrow it down quickly:
- If the error says “Access denied”, focus on credentials and privileges.
- If the error says “Unknown database”, check the database name in the hosting panel.
- If the error says “Communications link failure”, review host, port, and network reachability.
- If the error says “No suitable driver”, install or update the MySQL JDBC driver.
- If the site worked after restart but later failed, investigate pooling or leaked connections.
This method saves time because each error points to a different layer: configuration, access, connectivity, or runtime.
Best practices for JSP and MySQL on managed hosting
To reduce database connection issues on JSP hosting, keep the configuration simple and consistent. This is especially useful when you run a private Tomcat instance or separate JVM through a hosting control panel.
- Store database settings in one clear configuration file.
- Document the correct JDBC URL for the application.
- Use a MySQL connector version compatible with the selected Java version.
- Restart Tomcat after updates to the driver or connection settings.
- Keep the database account permissions minimal but sufficient.
- Avoid hardcoding temporary development values into production files.
- Monitor logs regularly after deployment.
These habits are especially helpful for JSP, servlet, and WAR-based applications that are deployed into a hosted Tomcat environment.
When to contact hosting support
Contact support if you have already checked the application configuration, database credentials, driver, and Tomcat service, but the connection still fails. A support team can usually confirm whether the database service is running, whether the account has the correct permissions, or whether there is a platform-level issue affecting the Java environment.
Useful information to provide includes:
- The exact error message from the logs.
- The database host, name, and user you are trying to use.
- Whether the application uses a datasource or direct JDBC connection.
- The Java version selected in My App Server.
- Whether the problem started after a change, migration, or redeploy.
FAQ
Why does my JSP page show a database error after deployment?
Because the application is still using development settings, missing the JDBC driver, or connecting to the wrong database host or user. Deployment often exposes configuration differences that were hidden on the local machine.
Can a database error be caused by Tomcat itself?
Yes. If Tomcat is stopped, misconfigured, or running without the correct driver, the JSP application may show database errors even though the underlying database is fine.
What is the first thing I should check?
Check the exact error message in the logs. It will usually tell you whether the issue is credentials, host, port, permissions, or driver loading.
Why do I get “Access denied” even though the password is correct?
The MySQL user may not have permission for that database, the username may be tied to a different database account, or the application may still be using an old saved password.
Do I need to restart My App Server after changing database settings?
Yes, in many cases. Restarting ensures Tomcat reloads the updated configuration and reconnects with the correct driver and credentials.
What if my application uses a remote MySQL server?
Then you also need to check network access, DNS, firewall rules, and remote host permissions. The database must allow connections from the hosting environment.
Conclusion
JSP database connection errors are usually caused by a small number of predictable issues: wrong credentials, incorrect JDBC URL values, missing MySQL driver files, incomplete database permissions, or Tomcat service problems. In a managed hosting setup with Plesk and My App Server, the fastest way to resolve them is to verify the configuration in the control panel, confirm that the JDBC driver is available, and restart the Java service after changes.
By checking the exact error message first and then following a structured troubleshooting path, you can usually identify the cause quickly and restore the application without unnecessary changes. For JSP hosting, stable database configuration, compatible Java and MySQL connector versions, and clean service control are the key factors that keep the site running reliably.