How to use traccar with custom stored procedure (postgresql 9.4+) ?

maxim-gis9 years ago

Hello everybody!
My name is Max

I think it will be interesting and useful to know.

  1. How to used traccar with custom stored procedure?

example of my procedure :
pr_event_data_point_insert(v_dev_id integer, v_record_num integer, v_device_time integer, v_latitude real, v_longtitude real, v_speed real, v_course real, v_other json)

query = "select pr_event_data_point_insert(" + this.dev_id + "," + recordNum + "," + deviceTime + "," + latitude + "," + longtitude + "," + speed + "," + course + ",'" + JSON.stringify(curOther) + "'::JSON)";

which solution is best for this?

  1. How or (Where) to find the list of default "values" in traccer (interpreter part) - :serverTime, :deviceTime, :fixTime, :valid, :latitude, :longitude, :altitude, :speed, ... etc.,

  2. How to add "unknown device" to devices "table" if it not found by default (1 connect)?

Thanks in advance.

P.S. Very useful project.

Anton Tananaev9 years ago
  1. You can put a call to stored procedure into the config file.

  2. In the default config.

  3. You need to register the device in the database. By default it's "devices" table.

maxim-gis9 years ago

Thank you Anton !
little refinements

1)
<entry key='database.insertPosition'>
call "my_stored_procedure"

This syntax is correct?

  1. (deviceId, protocol, serverTime, deviceTime, fixTime, valid, latitude, longitude, altitude, speed, course, address, attributes)
    VALUES (:deviceId, :protocol, :now, :time, :time, :valid, :latitude, :longitude, :altitude, :speed, :course, :address, :attributes);

Is it correct ?

  1. Whether the "traccar" will automatically work with the incoming traffic, if my device was not initially added to the database, oh then I add them?
Anton Tananaev9 years ago
  1. Something like that.

  2. Yes, those are the parameters.

  3. You need to register device first.

maxim-gis9 years ago

how to replace original (or use) jdbc driver postgresql 9.4.1208 JDBC 42!
it is important for my configuration.

https://jdbc.postgresql.org/download/postgresql-9.4.1208.jar

Thanks in advance.

Anton Tananaev9 years ago

Can you explain the importance?

maxim-gis9 years ago

my configuration:
pg server 9.5.1
java 1.8

P.S. I'm really need pg server 9.5.1 + java 1.8

I'm use some features from pg 9.5.1 and java 1.8

I have "custom build" of this software and "build" my "stack"
around it technologies

--> JSONB-modifying operators and functions
--> JDBC 4.2

Thanks in advance.

Anton Tananaev9 years ago

You can always update dependency if you customize the code anyway, but official Traccar doesn't use Java 8 yet.

maxim-gis9 years ago

OK. Thanks.