Traccar doesnt create tables using MySQL as db - OS: Windows 10

Alvesxvii3 years ago

Hi, I'd like to ask for some help as I'm having some issues with Traccar connectivity. Recently I donwloaded Traccar's last version and installed the server on my computer wich is a Windows 10 x64. I have no problems initiating the server and running it locally thourgh localhost:8082 with Oracle database.

The thing is, when I manage to replace the configuration file "Traccar.xml" to point out to a MySQL database, it won't recognize the following lines:

<entry key='database.driver'>com.mysql.cj.jdbc.Driver</entry>
<entry key='database.url'>jdbc:mysql://127.0.0.1:3306/td_project?serverTimezone=UTC&amp;useSSL=false&amp;allowMultiQueries=true&amp;autoReconnect=true&amp;useUnicode=yes&amp;characterEncoding=UTF-8&amp;sessionVariables=sql_mode=''</entry>
<entry key='database.user'>root</entry>
<entry key='database.password'></entry>

*My database "td_project" is empty. There aren't tables created on it.

At least I guess it is kinda ignoring them because I can't see any information related to it in the log file. It doesn't show any failure messages. Seems it just skip it and keep using the default Oracle db.

Note: I already tried editing Traccar.xml and restarting traccar service in the task manager multiple times but it doesnt help.

I have no clue of what can possibly be going on... I would appretiate any thoughts on this one... I read some related questions here in the forum talking about this same issue but the resolutions weren't very clear... Most people found out how to solve their problem but didn't returned to explicitly tell what they've done.

Thanks in advance!

PS: Here's the log lines I get from starting the server:

2022-05-06 22:21:37  INFO: HikariPool-1 - Starting...
2022-05-06 22:21:38  INFO: HikariPool-1 - Added connection conn0: url=jdbc:h2:./data/database user=SA
2022-05-06 22:21:38  INFO: HikariPool-1 - Start completed.
2022-05-06 22:21:38  INFO: Set default schema name to PUBLIC
2022-05-06 22:21:38  INFO: Clearing database change log checksums
2022-05-06 22:21:38  INFO: Successfully acquired change log lock
2022-05-06 22:21:39  INFO: Successfully released change log lock
2022-05-06 22:21:39  INFO: Successfully acquired change log lock
2022-05-06 22:21:39  INFO: Cannot load service: liquibase.parser.ChangeLogParser: liquibase.parser.core.json.JsonChangeLogParser Unable to get public no-arg constructor
2022-05-06 22:21:39  INFO: Cannot load service: liquibase.parser.ChangeLogParser: liquibase.parser.core.yaml.YamlChangeLogParser Unable to get public no-arg constructor
2022-05-06 22:21:40  INFO: Reading from PUBLIC.DATABASECHANGELOG
2022-05-06 22:21:40  INFO: Reading from PUBLIC.DATABASECHANGELOG
2022-05-06 22:21:40  INFO: Cannot load service: liquibase.hub.HubService: Provider liquibase.hub.core.StandardHubService could not be instantiated
2022-05-06 22:21:40  INFO: Successfully released change log lock
2022-05-06 22:21:40  INFO: Your platform does not provide complete low-level API for accessing direct buffers reliably. Unless explicitly requested, heap buffer will always be preferred to avoid potential system instability.
2022-05-06 22:21:41  INFO: Operating system name: Windows 10 version: 10.0 architecture: amd64
2022-05-06 22:21:41  INFO: Java runtime name: OpenJDK 64-Bit Server VM vendor: ojdkbuild version: 11.0.13+8-LTS
2022-05-06 22:21:41  INFO: Memory limit heap: 1462mb non-heap: 0mb
2022-05-06 22:21:41  INFO: Character encoding: Cp1252 charset: windows-1252
2022-05-06 22:21:41  INFO: Version: 4.15
2022-05-06 22:21:41  INFO: Starting server...
2022-05-06 22:21:41  WARN: Port disabled due to conflict - Address already in use: bind - BindException (...)
2022-05-06 22:21:41  INFO: jetty-10.0.7; built: 2021-10-06T19:34:02.766Z; git: da8a4553af9dd84080931fa0f8c678cd2d60f3d9; jvm 11.0.13+8-LTS
2022-05-06 22:21:42  INFO: Started o.t.w.@4493d6cb{/,null,AVAILABLE}
2022-05-06 22:21:42  INFO: Session workerName=node0
2022-05-06 22:21:42  WARN: JAXBContext implementation could not be found. WADL feature is disabled.
2022-05-06 22:21:43  INFO: Started o.e.j.s.ServletContextHandler@24b6c490{/,null,AVAILABLE}
2022-05-06 22:21:43  INFO: Started ServerConnector@b3bfcbb{HTTP/1.1, (http/1.1)}{0.0.0.0:8082}
2022-05-06 22:21:43  INFO: Started Server@17029b61{STARTING}[10.0.7,sto=0] @6669ms
Anton Tananaev3 years ago

Your server is still connecting to the default H2 database:

url=jdbc:h2:./data/database user=SA

You either haven't changed the right file or you haven't saved it or you haven't restarted the service.

By the way, the file is traccar.xml, not Traccar.xml.

Alvesxvii3 years ago

Hi Anton, first of all, thanks for your quick return.

  • I believe I've changed the right file since it's the only one inside C:\Program Files\Traccar\conf. I haven't changed "default.xml" because it told me not to do so according to:
< #Commented section !--

    DO NOT MODIFY THIS FILE. Use traccar.xml instead.

    -- #End of commented section >
  • It's indeed "traccar.xml" instead of "Traccar.xml". Don't know why I've typed it in capital...

Here's the full traccar.xml file. Am I missing something?

<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE properties SYSTEM 'http://java.sun.com/dtd/properties.dtd'>

<properties>

    <entry key='config.default'>./conf/default.xml</entry>

    < #Commented section !-- 

    This is the main configuration file. All your configuration parameters should be placed in this file.

    Default configuration parameters are located in the "default.xml" file. You should not modify it to avoid issues
    with upgrading to a new version. Parameters in the main config file override values in the default file. Do not
    remove "config.default" parameter from this file unless you know what you are doing.

    For list of available parameters see following page: https://www.traccar.org/configuration-file/

    

    <entry key='database.driver'>org.h2.Driver</entry>
    <entry key='database.url'>jdbc:h2:./data/database</entry>
    <entry key='database.user'>sa</entry>
    <entry key='database.password'></entry>

    -- #End of commented section>

    
    <entry key='database.driver'>com.mysql.cj.jdbc.Driver</entry>
    <entry key='database.url'>jdbc:mysql://127.0.0.1:3306/td_project?serverTimezone=UTC&amp;useSSL=false&amp;allowMultiQueries=true&amp;autoReconnect=true&amp;useUnicode=yes&amp;characterEncoding=UTF-8&amp;sessionVariables=sql_mode=''</entry>
    <entry key='database.user'>root</entry>
    <entry key='database.password'></entry>
    


    

</properties>
Alvesxvii2 years ago

Coming back to say I found out the issue... Turns out my configuration files weren't being ignored at all... I was using Sublime Text as my text editor in order to make changes in the configuration files... I replaced the code lines to use MySQL as database in traccar using it. Thing is I discovered that I was having some permissions issues while modificating those files in my Program Files > Traccar > conf. Windows was not allowing me to do such changes. I realised that once I tried opening traccar.xml with Window's default notepad text editor and changing the line codes... I won't allow me do that. I needed to save it as a new file in my desktop, delete the original one inside the conf folder and then move the edited one from desktop to conf. And just by doing that when I reloaded the server voilĂ ... MySQL connection was made and tables were created. That's it... I recommend checking user permissions while alterating files inside Program Files specially if you are using another text editor besides Windows notepad and you are facing the same issue that I was.