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 开发者_Go百科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?
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.
精彩评论