Reputation: 15
I have a problem with my double. It only shows 1 digit after the comma instead of putting everything in my mysql table:
public static double getFactionDtr(int id) throws SQLException{
double dtr = 1;
PreparedStatement queryStatement = FactionDatabase.createStatement("SELECT dtr FROM factionmanagement WHERE id = ?");
queryStatement.setInt(1, id);
ResultSet rs = queryStatement.executeQuery();
if(!rs.next()) {
return Double.valueOf(dtr);
}
dtr = rs.getInt("dtr");
queryStatement.close();
return Double.valueOf(dtr);
}
The result is 0.0
and in my mysql table 0.001
Upvotes: 0
Views: 709
Reputation: 11835
dtr = rs.getInt("dtr");
Here, you get an integer value from your result set which cannot contain a fractional part.
Replace it with
dtr = rs.getDouble("dtr");
Also, your final line does some strange thing: it wraps double
with Double
and then (using unboxinb) converts Double
back to double
:
return Double.valueOf(dtr);
Just return dtr
:
return dtr;
Upvotes: 1