New on LowEndTalk? Please Register and read our Community Rules.
[Solved][JAVA] H2 Database help
Hi, I am using a software called Traccar, it is used to track GPS. Several chinese GPS are fixed to send positive longitude, so if I use them in Mexico, they will locate in China. The conf says:
SELECT id, uniqueId as imei FROM devices; INSERT INTO positions (device_id, time, valid, latitude, longitude, altitude, speed, course, power, other) VALUES (:device_id, :time, :valid, :latitude, -:longitude, :altitude, :speed, :course, :power, :extended_info);
I placed the minus ( - ) on longitude, and now it works, but if the device sends the longitude correctly, it will reverse and send the longitude positive... how can I always make it negative? how can I use a variable there? Thanks
Comments
It's easy to solve this if you want ALL longitudes to be negative:
...but presumably you want some pos and some neg, and I don't know how the DB would know which are which...?
I knew I can do this on any other platform, but I don't know H2 nor Java
I did this:
I don't really know if this works on H2, and I am still waiting on the GPS to send a new coordinate to check if it worked or not
or ABS(?)*(-1)
The H2 Google Group is pretty active and the committers will probably help you out. But, I think you need to work on forming your question a bit more clearly. I use H2 daily along with Java (it is my main DB) and I am not quite sure what you are exactly asking.
Also, I try to avoid DB triggers, as they are always a little strange. If you can swap +/- in application code, as opposed to a db trigger, I think you will have luck.
This worked:
Thank you!!