MySQL configuration fails due to XML escaping in traccar.xml (SAXParseException)

Nst Alarcon 11 hours ago

Hello,

I noticed that the MySQL configuration example in the documentation uses a standard JDBC URL like:

jdbc:mysql://localhost/traccar?zeroDateTimeBehavior=round&serverTimezone=UTC&allowPublicKeyRetrieval=true...

However, when placing this inside traccar.xml, the server fails to start with:

SAXParseException (Config parsing error)

It seems the issue is that XML requires escaping special characters like "&", so the correct format should be:

&

instead of:

&

Also, for sessionVariables, using:

sql_mode=''

breaks XML and must be encoded as:

sql_mode=%27%27

So the working configuration becomes:

<entry key='database.url'>
jdbc:mysql://localhost/traccar?zeroDateTimeBehavior=round&amp;serverTimezone=UTC&amp;allowPublicKeyRetrieval=true&amp;useSSL=false&amp;allowMultiQueries=true&amp;autoReconnect=true&amp;useUnicode=yes&amp;characterEncoding=UTF-8&amp;sessionVariables=sql_mode=%27%27
</entry>

My question:
Would it be possible to update the documentation to reflect XML-safe configuration examples?

This could help avoid confusion for new installations.

Thanks!

Nst Alarcon 11 hours ago
<entry key='database.driver'>com.mysql.cj.jdbc.Driver</entry>
<entry key='database.url'>jdbc:mysql://localhost/traccar?zeroDateTimeBehavior=round&amp;serverTimezone=UTC&amp;allowPublicKeyRetrieval=true&amp;useSSL=false&amp;allowMultiQueries=true&amp;autoReconnect=true&amp;useUnicode=yes&amp;characterEncoding=UTF-8&amp;sessionVariables=sql_mode=%27%27</entry>
<entry key='database.user'>[USER]</entry>
<entry key='database.password'>[PASSWORD]</entry>
Anton Tananaev 9 hours ago

Fixed & escaping. It was broken in a recent website update. It used to be escaped correctly.

By the way sql_mode='' doesn't need to be escaped. It's valid XML as is.

Nst Alarcon 7 hours ago

Hi Anton,
thanks for addressing this so quickly. We encountered this during a deployment and confirmed it was related to the documentation. Glad it's now fixed — it will save others quite some time.
Thanks again for your continued work on Traccar!