Change database from H2 to Mysql

grphoto 7 years ago

I have install Traccar in centos-Cpanel. All worked fine with H2 but now i want to do mysql database instead. I dont mind to loose current data since i have only one device yet.

I use the example file (in server i have 2 domain, traccar is working fine with H2 in 1 with virtualhost-proxy)

<entry key='database.driver'>com.mysql.jdbc.Driver</entry> 
<entry key='database.url'>jdbc:mysql://localhost:3306/mydomain_app?useSSL=false&amp;allowMultiQueries=true&amp;autoReconnect=true&amp;useUnicode=yes&amp;characterEncoding=UTF-8&amp;sessionVariables=sql_mode=''</entry>
<entry key='database.user'>mydomain_user</entry> 
<entry key='database.password'>123456</entry>

With H2 is ok when i replace the database data it keeps loading and no table created in database. Maybe some other syntax in mysql since working in domain?

Anton Tananaev 7 years ago

Have you checked logs?

grphoto 7 years ago

I cannot understand the problem from there.
Btw thank you for your great job and the great tool.

I see some errors

Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Caused by: java.net.ConnectException: Connection refused (Connection refused)
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
Caused by: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
Anton Tananaev 7 years ago

I think the error is pretty self-explanatory. Server can't connect to the database.

grphoto 7 years ago

Yes, thank you for your time, i have understand that, since no creation of tables also, thats why i ask, maybe has some other person experience with cpanel-centos-domains, maybe some other syntax in

mysql://localhost:3306/mydomain_app

i have try several cases there with no luck. Im gonna try with more tests there until then.

I had also firewall CSF, i put 3306 port in allow, after i close it full etc

grphoto 7 years ago

Finally it worked. Maybe my mistake is that i restarting the whole server, i have try with double ./startDaemon.sh inside /opt/traccar/bin/
and now worked. Thank you for your time and your great work.