数据库服务器连接报错求助:ArrayIndexOutOfBoundsException异常
First off, let’s break down the issues in your configuration that are likely causing this database connection error:
Malformed JDBC URL (the primary culprit)
Looking at yourspring.datasource.url, there’s a critical syntax mistake. You’ve writtenjdbc:mysql://159.65.200.68:3306/timYcreateDatabaseIfNotExist=true— notice that after your database nametimY, you’re missing a?to separate the database path from the query parameters. This breaks the URL parser, which tries to split parameters incorrectly and throws anArrayIndexOutOfBoundsException. Fix it to:spring.datasource.url=jdbc:mysql://159.65.200.68:3306/timY?createDatabaseIfNotExist=true&useUnicode=true&useJDBCCompliantTimezoneShift=true&autoReconnect=true&useLegacyDatetimeCode=false&serverTimezone=UTCDeprecated Hibernate Naming Strategy
The propertyspring.jpa.hibernate.naming_strategyis outdated in newer Spring Boot versions. Replace it with a modern alternative based on your needs:- For physical naming (controls how database tables/columns are named):
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl - For implicit naming (maps entity names to database names):
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl
If you specifically need the old EJB3 behavior, you can keep
org.hibernate.cfg.EJB3NamingStrategybut note it’s no longer maintained.- For physical naming (controls how database tables/columns are named):
Truncated Database Platform Property
Yourspring.jpa.database-p...is cut off. Complete it to specify the correct Hibernate dialect for your MySQL version, like:spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect(Use
MySQL5Dialectif you’re on an older MySQL version.) This ensures Hibernate generates SQL compatible with your database.
After fixing these, restart your app and see if the exception goes away. If it persists, share the full stack trace of the ArrayIndexOutOfBoundsException — that’ll help us dig deeper into driver version issues or other connection-related code problems.
内容的提问来源于stack exchange,提问作者abstract christmas tree

