Good afternoon, I get coordinates on the GPS client in the String type using for this

String.format( "%1$.4f", location.getLongitude()); 

On the server you need to put them in a table with double fields. I tried without converting I get an error

 Data truncated for column 'latitude' at row 1 

I tried to send values ​​without using String.format, but then incriminatingly huge hexadecimal values ​​come. Tried to use

 longitude=Double.parseDouble(din.readUTF()) 

server does not accept values. You can try parsing regular files, but this will add code.

Maybe there is a less costly option to convert?

Type of field in the table

Data type DOUBLE Length / Value 1.0

  • here boolean? - iksuy
  • @iksuy apparently should be double . Judging by Double.parseDouble() . - αλεχολυτ
  • @iksuy yes correctly corrected. - Varg Sieg
  • and what type of fields in the database? - Komdosh
  • @Komdosh double and comes in a string - Varg Sieg

1 answer 1

Increase the size of the field in the database, for example:

alter table table_name alter column row_name DECIMAL(10,0);

  • Comma to a point as a separator try to change - Chubatiy
  • Error with a dot instead of a comma please show. And further. In your SQL query for insert is the field value not accidentally escaped? For example, "'" +value+ "'" ? - Chubatiy
  • @Chubatiy yes here is the query `" INSERT INTO entre (id, latitude ")" "VALUES ('" + id + "', '" + latitude + "')" - Varg Sieg
  • @VargSieg, it seems like you need to use the exact same point - Ksenia
  • @VargSieg, and write more, please, what your coordinate looks like in the string version - Ksenia