Issue with Queries to tc_devices Table Despite Configuration Change

Krzysztof Kaszaa month ago

Hi,
Despite changing the queries in the traccar.xml file to reference the devices table, the application still queries tc_devices. Below is a snippet from the log:

2025-03-11 23:54:49 DEBUG: execute query: SELECT * FROM tc_devices WHERE uniqueId = ?

I changed the configuration to:

<entry key='database.selectDevices'>
    SELECT * FROM devices;
</entry>
<entry key='database.selectDeviceByUniqueId'>
    SELECT * FROM devices WHERE TRIM(uniqueId) = TRIM(:uniqueId) LIMIT 1;
</entry>

Still, the application continues to reference tc_devices.
Has anyone faced a similar issue? How can I resolve this?

Thanks in advance!

Best regards,
Krzysztof Kasza

Anton Tananaeva month ago

Are you using the latest official release?

Krzysztof Kaszaa month ago

Hi,

I’m using the official Traccar 6.6 version from the traccar-windows-64-6.6 package, but I’m having trouble with my configuration and can’t figure out what’s wrong. Below is a snippet of my traccar.xml file. Could someone take a look and let me know if there’s anything incorrect or out of place?

<entry key='database.selectDevices'>
    SELECT * FROM devices;
</entry>
<entry key='database.selectDeviceByUniqueId'>
    SELECT * FROM devices WHERE TRIM(uniqueId) = TRIM(:uniqueId) LIMIT 1;
</entry>
<entry key='database.selectDevice'>
    SELECT * FROM devices WHERE id = :id;
</entry>
<entry key='database.insertPosition'>
    INSERT INTO positions (
        device_id, protocol, time, valid, latitude, longitude, 
        altitude, speed, course, address, other
    ) VALUES (
        :deviceId, :protocol, :time, :valid, :latitude, :longitude, 
        :altitude, :speed, :course, :address, :other
    );
</entry>
<entry key='database.updateLatestPosition'>
    UPDATE devices SET latestPosition_id = :id WHERE id = :deviceId;
</entry>

If anyone has suggestions or needs more details, please let me know. Thanks in advance for your help!

Best regards,
Krzysztof Kasza

Anton Tananaeva month ago

Those configuration parameters don't exist:

https://www.traccar.org/configuration-file/

Krzysztof Kaszaa month ago

Hi,
Thank you for your response. I understand that the SQL queries I previously used have been removed in the latest version of Traccar and that the system now handles these queries automatically. However, I have some doubts about how to properly configure SQL queries in the traccar.xml file in the new version.
I would like to know the best way to connect to my database and adjust the SQL queries related to devices and positions. I have the devices and positions tables available, and previously, I used queries like the ones below:

<entry key='database.selectDevices'>
    SELECT * FROM devices;
</entry>
<entry key='database.selectDeviceByUniqueId'>
    SELECT * FROM devices WHERE TRIM(uniqueId) = TRIM(:uniqueId) LIMIT 1;
</entry>
<entry key='database.selectDevice'>
    SELECT * FROM devices WHERE id = :id;
</entry>
<entry key='database.insertPosition'>
    INSERT INTO positions (
        device_id, protocol, time, valid, latitude, longitude, 
        altitude, speed, course, address, other
    ) VALUES (
        :deviceId, :protocol, :time, :valid, :latitude, :longitude, 
        :altitude, :speed, :course, :address, :other
    );
</entry>
<entry key='database.updateLatestPosition'>
    UPDATE devices SET latestPosition_id = :id WHERE id = :deviceId;
</entry>

I would appreciate examples of how these queries should be written in the latest version to align with the new database management methods in Traccar.
Thank you in advance for your help and any guidance!

Best regards,
Krzysztof Kasza

Anton Tananaeva month ago

Queries are no longer configurable. If you want to change them, you would have to do it in the code.