Enzomatric
Enzomatric

Reputation: 497

Hibernate cannot parse connection String

According to Mysql documentation, this connection string from xml configuration file is correct:

<property name="hibernate.connection.url">jdbc:mysql:///database?useSSL=false&allowPublicKeyRetrieval=true</property>

And Mysql Connector/J parses the query parameters correctly.

However same connection string fails to be parsed correctly when Hibernate configures StandardServiceRegistryBuilder as the parser expects that that "&" is a start of an entity name. I found another suggestion to replace "&" with "&amp;" but this doesn't work either.

So what is the correct way of providing more than 1 parameter in hibernate xml configuration file? I'm using Mysql 8, Connector 8.0.13, Java 11 and Hibernate 5.3.7.

Upvotes: 3

Views: 1216

Answers (2)

romeucr
romeucr

Reputation: 229

I had the same problem and it worked to me using &amp; to concatenate parameters:

<property name="javax.persistence.jdbc.url" 
                value="jdbc:mysql://localhost/pbdatabase?useSSL=false&amp;serverTimezone=UTC&amp;allowPublicKeyRetrieval=true" />

Upvotes: 4

Latera
Latera

Reputation: 28

Would you try below?

<property name="hibernate.connection.url" value="jdbc:mysql:///database?useSSL=false&allowPublicKeyRetrieval=true" />

Upvotes: 0

Related Questions