HowTo: MariaDB configuration in traccar.xml

deep7 years ago

We suppose that you have a basic knowledge on how to install a DB (Data Base) and server and you already has opened the necessary ports if the installation is outside local server environment!
Using phpMyAdmin or Adminer you can manipulate the DB Server and create an empty DB ([DATABASE])
Altering user with apropiate privileges and credentials ([DB_USERNAME] [DB_PASSWORD]) to access this DB!

To make things work first of all you'll need to download MariaDB JAVA driver which doesn't come with TRACCAR!!!!

https://downloads.mariadb.org/connector-java/

In traccar.xml you must add a path to that driverfile in the example below which I use the version of JAVA connector to MariaDB is version 2.0.1 meanwhile a version 2.0.3 was released!
EDIT: Release version of connector is 2.2.1

<entry key='database.driver'>org.mariadb.jdbc.Driver</entry>
<entry key='database.driverFile'>./lib/mariadb-java-client-2.0.1.jar</entry>

<entry key='database.url'>jdbc:mariadb://[HOST/IP]:3306/[DATABASE]?allowMultiQueries=true&autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8&sessionVariables=sql_mode=''</entry>
<entry key='database.user'>[DB_USERNAME]</entry> 
<entry key='database.password'>[DB_PASSWORD]</entry>

That's it just replace [HOST/IP] [DATABASE] [DB_USERNAME] [DB_PASSWORD] with proper/ own values!

Anton Tananaev7 years ago

You don't need to download or install anything. MariaDB is fully compatible with MySQL, so you can use the same instructions as MySQL:

https://www.traccar.org/mysql/

MySQL driver is already included with Traccar package.

deep7 years ago

@Anton, I thing I can oppose your vision as I pass more than 36 hours debugging on freshly installed servers with MariaDB and the only success and working solution was downloading the appropriate database driver and instruct TRACCAR to use it in the config as the example above!
I just want to share my knowledge, nothing more, nothing less!
Again respect for the great work!

@all - using mariaDB has some major benefits as the DB engine is free (OpenSource) as TRACCAR itself!
MySQL is replaced in all next major *NIX distros with MariaDB - example: Debian 9 Stretch! which is released!!! yeah
MariaDB has backward/onward/forward compatibility and tools and strong community which means it just work as most of Open Source projects before they monetize it as support or some extra goodies!

Anton Tananaev7 years ago

I have tried it before and it worked without any issues. Possibly something changed in more recent versions.

By the way, MySQL is also an open source database.

deep7 years ago

It's open sourced by Oracle, I can trust more on Community than in a corporation ;)
(it's mine point of view)
I respect everyones opinion as everyone is a human as we are ;)

deep7 years ago

Dear Anton,
after upgrading the JAVA this is what happen.
Can you provide some tips?!

WARNING|wrapper|Service traccar|17-08-08 22:02:44|YAJSW: yajsw-stable-12.09
WARNING|wrapper|Service traccar|17-08-08 22:02:44|OS   : Windows 7/6.1/amd64
WARNING|wrapper|Service traccar|17-08-08 22:02:44|JVM  : Oracle Corporation/1.8.0_141/C:\Program Files\Java\jre1.8.0_141/64
INFO|wrapper|Service traccar|17-08-08 22:02:45|start delay: 0
INFO|wrapper|Service traccar|17-08-08 22:02:45|started process with pid 3956
INFO|3956/0|Service traccar|17-08-08 22:02:46|[INFO] StandardFileSystemManager - Using "C:\Windows\TEMP\vfs_cache" as temporary files store.
INFO|3956/0|Service traccar|17-08-08 22:02:47|[main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
INFO|3956/0|Service traccar|17-08-08 22:02:47|[main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed.
INFO|3956/0|Service traccar|17-08-08 22:02:48|INFO 8/8/17 10:02 PM: liquibase: Clearing database change log checksums
INFO|3956/0|Service traccar|17-08-08 22:02:48|INFO 8/8/17 10:02 PM: liquibase: Successfully acquired change log lock
INFO|3956/0|Service traccar|17-08-08 22:02:48|INFO 8/8/17 10:02 PM: liquibase: Successfully released change log lock
INFO|3956/0|Service traccar|17-08-08 22:02:48|INFO 8/8/17 10:02 PM: liquibase: Successfully acquired change log lock
INFO|3956/0|Service traccar|17-08-08 22:02:49|INFO 8/8/17 10:02 PM: liquibase: Reading from traccar.DATABASECHANGELOG
INFO|3956/0|Service traccar|17-08-08 22:02:50|INFO 8/8/17 10:02 PM: liquibase: Reading from traccar.DATABASECHANGELOG
INFO|3956/0|Service traccar|17-08-08 22:02:50|INFO 8/8/17 10:02 PM: liquibase: ./schema/changelog-master.xml: changelog-3.8::changelog-3.8-dropuniquetoken::author: Change set changelog-3.8::changelog-3.8-dropuniquetoken::author failed, but failOnError was false.  Error: (conn:4173) Can't DROP 'uk_user_token'; check that column/key exists [Failed SQL: ALTER TABLE traccar.users DROP KEY uk_user_token]
INFO|3956/0|Service traccar|17-08-08 22:02:50|INFO 8/8/17 10:02 PM: liquibase: Successfully released change log lock
INFO|3956/0|Service traccar|17-08-08 22:02:50|[main] INFO org.eclipse.jetty.util.log - Logging initialized @5391ms
INFO|3956/0|Service traccar|17-08-08 22:02:52|java.lang.reflect.InvocationTargetException
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at java.lang.reflect.Method.invoke(Unknown Source)
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at org.rzo.yajsw.app.WrapperJVMMain.executeMain(WrapperJVMMain.java:60)
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at org.rzo.yajsw.app.WrapperJVMMain.main(WrapperJVMMain.java:43)
INFO|3956/0|Service traccar|17-08-08 22:02:52|Caused by: org.jboss.netty.channel.ChannelException: Failed to bind to: 0.0.0.0/0.0.0.0:5100
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:272)
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at org.traccar.TrackerServer.start(TrackerServer.java:117)
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at org.traccar.ServerManager.start(ServerManager.java:81)
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at org.traccar.Main.main(Main.java:38)
INFO|3956/0|Service traccar|17-08-08 22:02:52|	... 6 more
INFO|3956/0|Service traccar|17-08-08 22:02:52|Caused by: java.net.BindException: Address already in use: bind
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at sun.nio.ch.Net.bind0(Native Method)
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at sun.nio.ch.Net.bind(Unknown Source)
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at sun.nio.ch.Net.bind(Unknown Source)
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at org.jboss.netty.channel.socket.nio.NioServerBoss$RegisterTask.run(NioServerBoss.java:193)
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at org.jboss.netty.channel.socket.nio.AbstractNioSelector.processTaskQueue(AbstractNioSelector.java:391)
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:315)
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at org.jboss.netty.channel.socket.nio.NioServerBoss.run(NioServerBoss.java:42)
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
INFO|3956/0|Service traccar|17-08-08 22:02:52|	at java.lang.Thread.run(Unknown Source)
INFO|wrapper|Service traccar|17-08-08 22:02:52|calling onStop
INFO|wrapper|Service traccar|17-08-08 22:02:52|Win service stop - timeout: 30000
INFO|wrapper|Service traccar|17-08-08 22:02:52|Win service wrapper.control -> stopping application
INFO|wrapper|Service traccar|17-08-08 22:02:52|Win service stop - after shutdown
INFO|wrapper|Service traccar|17-08-08 22:02:52|Win service stop - before notify
INFO|wrapper|Service traccar|17-08-08 22:02:52|Win service terminated

Reversing didn't help!
The server right now is on Windows 7 SP1 machine, but will be migrated soon to Debian!
The DB is mariaDB with the latest mariadb-java-client-2.1.0.jar
The connection to the DB is OK I'll check with HeidiSQL and all data is readable!
Thank you in advance!

N.B. This was strange:

INFO|3940/0|Service traccar|17-08-08 22:08:58|INFO 8/8/17 10:08 PM: liquibase: ./schema/changelog-master.xml: changelog-3.8::changelog-3.8-dropuniquetoken::author: Change set changelog-3.8::changelog-3.8-dropuniquetoken::author failed, but failOnError was false.  Error: (conn:4184) Can't DROP 'uk_user_token'; check that column/key exists [Failed SQL: ALTER TABLE traccar.users DROP KEY uk_user_token]
INFO|3940/0|Service traccar|17-08-08 22:08:58|INFO 8/8/17 10:08 PM: liquibase: Successfully released change log lock
INFO|3940/0|Service traccar|17-08-08 22:08:58|[main] INFO org.eclipse.jetty.util.log - Logging initialized @5790ms
INFO|3940/0|Service traccar|17-08-08 22:09:00|java.lang.reflect.InvocationTargetException
Anton Tananaev7 years ago

You have port conflict with some other process.

deep7 years ago

I'll donate and apreciate your efforts and help!
Slav to the roots ;)

Respect!

deep6 years ago

New MariaDB JAVA connector is available version 2.2.2
All versions for different flavours can be found here
https://downloads.mariadb.com/Connectors/java/

Direct link to the lates version can be found here
https://downloads.mariadb.com/Connectors/java/connector-java-2.2.2/mariadb-java-client-2.2.2.jar

Snagles6 years ago

A new version is there:

mariadb-java-client-2.2.3.jar

AsifB5 years ago

I am getting the following error while trying to use the mariadb JDBC driver -

Mar 14 16:05:18 ip-172-31-23-55 traccar: Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InaccessibleObjectException: Unable to make void jdk.internal.loader.ClassLoaders$AppClassLoader.appendToClassPathForInstrumentation(java.lang.String) accessible: module java.base does not "opens jdk.internal.loader" to unnamed module @40a4337a
Mar 14 16:05:18 ip-172-31-23-55 traccar: at org.traccar.Main.run(Main.java:152)
Mar 14 16:05:18 ip-172-31-23-55 traccar: at org.traccar.Main.main(Main.java:104)
Mar 14 16:05:18 ip-172-31-23-55 traccar: Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make void jdk.internal.loader.ClassLoaders$AppClassLoader.appendToClassPathForInstrumentation(java.lang.String) accessible: module java.base does not "opens jdk.internal.loader" to unnamed module @40a4337a
Mar 14 16:05:18 ip-172-31-23-55 traccar: at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:340)
Mar 14 16:05:18 ip-172-31-23-55 traccar: at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:280)
Mar 14 16:05:18 ip-172-31-23-55 traccar: at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:198)
Mar 14 16:05:18 ip-172-31-23-55 traccar: at java.base/java.lang.reflect.Method.setAccessible(Method.java:192)
Mar 14 16:05:18 ip-172-31-23-55 traccar: at org.traccar.database.DataManager.initDatabase(DataManager.java:113)
Mar 14 16:05:18 ip-172-31-23-55 traccar: at org.traccar.database.DataManager.<init>(DataManager.java:89)
Mar 14 16:05:18 ip-172-31-23-55 traccar: at org.traccar.Context.init(Context.java:389)
Mar 14 16:05:18 ip-172-31-23-55 traccar: at org.traccar.Main.run(Main.java:110)
Mar 14 16:05:18 ip-172-31-23-55 traccar: ... 1 more
Mar 14 16:05:19 ip-172-31-23-55 systemd: traccar.service: main process exited, code=exited, status=1/FAILURE
Mar 14 16:05:19 ip-172-31-23-55 systemd: Unit traccar.service entered failed state.
Mar 14 16:05:19 ip-172-31-23-55 systemd: traccar.service failed.

MySQL drivers are working fine and I am staying with that. The post here is for academic interest to see if anyone has solved this issue.