Longbiao CHEN
Longbiao CHEN

Reputation: 1053

Java+sqlite REAL field to String

I'm using Sqlite with Java using SQLiteJDBC. When querying sqlite, I've found out that these two return different things:

String str = result.getDouble("field_name").toString();
String str = result.getString("field_name");

The latter implicitly rounds up the digit of the REAL number in sqlite, and converts it to String. The former doesn't do the round up thing. Is this a bug of sqlite JDBC implementation or is this a common sense in SQL queries?

Upvotes: 1

Views: 1065

Answers (1)

Adeel Ansari
Adeel Ansari

Reputation: 39907

No, its not a bug, definitely. In the former, toString() method of Double class is invoked. Whereas, in the latter case, SQLLite implementation is working.

Upvotes: 2

Related Questions