Valid field does not insert in mysql database.

ont20169 years ago

Hi Anton Tananaev

Traccar is the good job for your gps tracking project since it works great as aspect. I have found some mistake from the valid field in mysql database so that they can not saved them at all. Please look into my query report.

| 52300 | meitrack |        2 | 2016-03-20 09:48:24 | 2016-03-20 09:47:10 | 2016-03-20 09:47:10 |      | 1x.xxx868 | 1xx.xxx611 |        0 |        0 |    240 | Nonthaburi TH                 | {"event":35,"sat":"11","gsm":"11","hdop":"0.7","odometer":"13052","runtime":"4070943","mcc":520,"mnc":3,"lac":46025,"cid":42966904,"status":"0400","adc1":0,"adc2":0,"adc3":0,"battery":395,"power":1218,"event-data":"00000001","fuel":0.0,"ip":"xxxxxxxxxxxxx"}   
| 52299 | teltonika |        4 | 2016-03-20 09:47:48 | 2016-03-20 09:46:27 | 2016-03-20 09:46:27 |      | 1xx.xxx311 | 1xx.xxx607 |      -51 |     0 |      0 | Nonthaburi, TH                 | {"priority":0,"sat":11,"event":0,"power":1,"io69":1,"io240":0,"io80":0,"io21":2,"io239":0,"io79":0,"io9":12084,"io181":16,"io182":8,"io66":12147,"io24":0,"io205":18263,"io206":1141,"io72":0,"io67":4089,"io68":0,"io199":0,"io241":52005,"io78":0,"ip":"1.47.34.113"}    |
Anton Tananaev9 years ago

What's the mistake?

ont20169 years ago

The valid is locate between fixTime and latitude. They show null in the database.

fixTime | valid | latitude
2016-03-20 14:17:40 | | 13.886868

Anton Tananaev9 years ago

It's not possible to be null with default configuration. Have you modified any thing in the config file?

ont20169 years ago

Hi Anton,

Here is an addition for my traccar.xml.

<entry key='database.insertPosition'>
        INSERT INTO positions (deviceId, protocol, serverTime, deviceTime, fixTime, valid, latitude, longitude, altitude, speed, course, attributes)
        VALUES (:deviceId, :protocol, :now, :time, :time, :valid, :latitude, :longitude, :altitude, :speed, :course, :attributes);
</entry>

Here is my table positions descripton, since they do not have values in valid record.

mysql> desc positions;
+------------+---------------+------+-----+---------------------+-----------------------------+
| Field      | Type          | Null | Key | Default             | Extra                       |
+------------+---------------+------+-----+---------------------+-----------------------------+
| id         | int(11)       | NO   | PRI | NULL                | auto_increment              |
| protocol   | varchar(128)  | YES  |     | NULL                |                             |
| deviceId   | int(11)       | NO   | MUL | NULL                |                             |
| serverTime | timestamp     | NO   |     | CURRENT_TIMESTAMP   | on update CURRENT_TIMESTAMP |
| deviceTime | timestamp     | NO   |     | 0000-00-00 00:00:00 |                             |
| fixTime    | timestamp     | NO   |     | 0000-00-00 00:00:00 |                             |
| valid      | bit(1)        | NO   |     | NULL                |                             |
| latitude   | double        | NO   |     | NULL                |                             |
| longitude  | double        | NO   |     | NULL                |                             |
| altitude   | float         | NO   |     | NULL                |                             |
| speed      | float         | NO   |     | NULL                |                             |
| course     | float         | NO   |     | NULL                |                             |
| address    | varchar(512)  | YES  |     | NULL                |                             |
| attributes | varchar(4096) | NO   |     | NULL                |                             |
+------------+---------------+------+-----+---------------------+-----------------------------+
14 rows in set (0.00 sec)
Anton Tananaev9 years ago

As you can see the "valid" field cannot be null. I'm not sure how you managed to get null in there.