Wildfly 19无法连接MySQL:时区配置错误求助
Hey there! Let's sort out this connection issue you're hitting—it's a super common problem when using MySQL 8.0+ connectors with WildFly, so don't worry, we'll get it fixed quickly.
The error message about the unrecognized timezone 'Mitteleuropäische Sommerzeit' tells us exactly what's wrong: MySQL 8.0 changed how it handles timezones, and it doesn't recognize that localized timezone name anymore. We just need to add a specific timezone parameter to your datasource configuration.
Here's how to fix it step by step:
Locate your WildFly configuration file
If you're running WildFly in standalone mode (typical for beginners), openstandalone/configuration/standalone.xml(orstandalone-full.xmlif you're using the full profile) in a text editor.Find your MySQL datasource definition
Search for the<datasource>block linked to your MySQL connection—it should have adriver-namematching yourmysql-connector-java-8.0.20.jardriver.Update the connection URL with the timezone parameter
In the<connection-url>element, append?serverTimezone=Europe/Berlin(since 'Mitteleuropäische Sommerzeit' refers to Central European Summer Time, this is the standard timezone ID MySQL recognizes). Alternatively, useUTCfor a universal timezone that avoids daylight saving time headaches.
Example updated URL:<connection-url>jdbc:mysql://your-db-host:3306/your-db-name?serverTimezone=Europe/Berlin</connection-url>Save and restart WildFly
Close the configuration file, then stop and restart your WildFly server to apply the changes.Retest the datasource connection
Head back to the WildFly admin console and test the connection—it should now work without the timezone error.
A quick tip: Using UTC is often safer for server applications because it eliminates confusion from daylight saving time transitions. If you go that route, your connection URL would look like:
<connection-url>jdbc:mysql://your-db-host:3306/your-db-name?serverTimezone=UTC</connection-url>
That's it! This should resolve the "WFLYJCA0047: Connection is not valid" error caused by the timezone mismatch.
内容的提问来源于stack exchange,提问作者Fabi

