3

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.

2
  • Could you post the error you get when you use the '&amp;' variant? Commented Mar 10, 2019 at 18:09
  • With the &amp;' connection string cannot be parsed in Connector/J. When getting query properties,you end up with amp key with no value. Commented Mar 10, 2019 at 20:56

2 Answers 2

4

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" />
Sign up to request clarification or add additional context in comments.

Comments

0

Would you try below?

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

2 Comments

Unfortunately, it is same problem "The reference to entity "allowPublicKeyRetrieval" must end with the ';' delimiter."
How about <property name="hibernate.connection.url" value="jdbc:mysql:///database?useSSL=false&amp;allowPublicKeyRetrieval=true" /> ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.