Save data to ms sql in my own tables

Good day! I install traccar system, and try configurate it to my own database on MS SQL. Connection to DB is worked, no problem. Data from GPS are comming. But in log traccar wrote this: "WARN: Unknown device - 1071418". I create table with ID GPS. In config wrote new strings:

<entry key='database.selectAllDevices'>
    SELECT CONCAT('1', VehicleID) AS id, VehicleID AS uniqueId FROM Vehicles 
</entry>

<entry key='database.insertPosition'>
    START TRANSACTION;
        INSERT INTO VehicleLog (VehicleID, X, Y, Speed, Course, LogTime, DataType)
        VALUES (:deviceId, Round(:latitude *1000000,0), Round(:longitude*1000000,0), Round(dbo.lesser(250,:speed),0), Round(dbo.lesser(180,:course/2),0), :fixTime, 50);
    COMMIT;
</entry>

It is nessesary create table with ID GPS ? Can traccar save data from unknown trackers?

Please, help me to connect traccar with my DB.

Thanks!

Anton Tananaev7 years ago

You have to have a table with devices with ids. You can configure Traccar to automatically register unknown devices.

Thanks. Now devices automaticaly register in DB. But new error:

2018-10-16 13:43:33 DEBUG: [a70f22a8: 5167 > 192.168.100.30] HEX: 11
2018-10-16 13:43:33  INFO: Query not provided: database.selectDevices
2018-10-16 13:43:33  WARN: The statement must be executed before any results can be obtained. - SQLServerException (... < QueryBuilder:479 < DataManager:453 < BaseObjectManager:87 < ...)
2018-10-16 13:43:33 DEBUG: [a70f22a8: 5167 > 192.168.100.30] HEX: 11
2018-10-16 13:43:33  INFO: Query not provided: database.selectDevices
2018-10-16 13:43:33  WARN: The statement must be executed before any results can be obtained. - SQLServerException (... < QueryBuilder:479 < DataManager:453 < BaseObjectManager:87 < ...)

No I have simple ISERT Query for test:

INSERT INTO Vehicles (VehicleID)
        VALUES (:deviceId)

VehicleID - varchar(256)

and it not worked.

I'm tryed install version 4.1.
The error "The statement must be executed before any results can be obtained" is still here.
I tryed different methods - not working.

Ok. I'm think. Let's give traccar create tables in DB...
Tables were created. Server started.
But now it write all data in DB in one Device ID.

2018-10-22 16:12:18  INFO: [8190a2a3] id: 1071535, time: 2018-10-22 16:12:03, lat: 47.21169, lon: 39.68880, speed: 44.0, course: 82.0
2018-10-22 16:12:18  INFO: [8190a2a3: 5167 > 192.168.100.30] HEX: 11
2018-10-22 16:12:18  INFO: [8190a2a3] id: 1071535, time: 2018-10-22 16:12:13, lat: 47.21195, lon: 39.69052, speed: 50.0, course: 75.0
2018-10-22 16:12:18  INFO: [8190a2a3: 5167 > 192.168.100.30] HEX: 11

When i tryed it with my own tables ID of Devices was good and different.

Protocol: Wialon Retranslator with many devices

Can You help me?

Anton Tananaev7 years ago

If data is coming from same network connection, by default Traccar would re-use cached id. You can use decoder.ignoreSessionCache config parameter to disable this behaviour.

Ok. It works! Thanks!
Meanwhile with my own tables still don't work. And I had to created trigger in DB for writing to my tables.

Some times in log:

2018-10-24 10:40:14 ERROR: LEAK: {}.release() was not called before it's garbage-collected. See http://netty.io/wiki/reference-counted-objects.html for more information.{}
2018-10-24 10:40:14 ERROR: LEAK: {}.release() was not called before it's garbage-collected. See http://netty.io/wiki/reference-counted-objects.html for more information.{}
2018-10-24 10:40:14 ERROR: LEAK: {}.release() was not called before it's garbage-collected. See http://netty.io/wiki/reference-counted-objects.html for more information.{}

Is it dangerous error?

Anton Tananaev7 years ago

Please upload full log file somewhere, so I can check the issue.

Link to yandex disk

I running now traccar for tests so file is small

Anton Tananaev7 years ago

I have fixed the issue:

https://github.com/traccar/traccar/commit/3a008c877056234e525587dbb339e5c950748b9a

But I don't think it's critical. You can probably safely use current version.

Very big thanks!