Java Question ResultSet.getDouble gives 4179.0 instead of the expected 4179

DonManfred

Expert
Licensed User
Longtime User
B4X:
ResultSet rs = st.executeQuery(query);
ResultSetMetaData rsmd = rs.getMetaData();
[..]
while(rs.next()) {
  Recordcount = Recordcount+1;
  String csv = "[";
  int numColumns = rsmd.getColumnCount();
  for (int i=1; i<numColumns+1; i++) {
    if (i!=1){
        csv = csv+",";                                  
    }

    String column_name = rsmd.getColumnName(i);
    //app.Log("col:"+column_name+"/"+rsmd.getPrecision(i)+"/"+rsmd.getScale(i));                              
  if(rsmd.getColumnType(i)==java.sql.Types.ARRAY){
      csv = csv+rs.getArray(column_name);                                  
  } else if(rsmd.getColumnType(i)==java.sql.Types.BIGINT){
      csv = csv+rs.getInt(column_name);                                  
  } else if(rsmd.getColumnType(i)==java.sql.Types.BOOLEAN){
      csv = csv+rs.getBoolean(column_name);                                  
  } else if(rsmd.getColumnType(i)==java.sql.Types.BLOB){
      csv = csv+rs.getBlob(column_name);                                  
  } else if(rsmd.getColumnType(i)==java.sql.Types.DOUBLE){
        app.Log("col:"+column_name+"/"+rs.getDouble(column_name));                              
      csv = csv+rs.getDouble(column_name);                                  
  } else if(rsmd.getColumnType(i)==java.sql.Types.FLOAT){
      csv = csv+rs.getFloat(column_name);                                  
  } else if(rsmd.getColumnType(i)==java.sql.Types.INTEGER){
      csv = csv+rs.getInt(column_name);                                  
  } else if(rsmd.getColumnType(i)==java.sql.Types.NVARCHAR){
      csv = csv+rs.getNString(column_name);                                  
  } else if(rsmd.getColumnType(i)==java.sql.Types.VARCHAR){
      csv = csv+rs.getString(column_name);                                  
  } else if(rsmd.getColumnType(i)==java.sql.Types.TINYINT){
      csv = csv+rs.getInt(column_name);                                  
  } else if(rsmd.getColumnType(i)==java.sql.Types.SMALLINT){
      csv = csv+rs.getInt(column_name);                                  
  } else if(rsmd.getColumnType(i)==java.sql.Types.DATE){
      csv = csv+rs.getDate(column_name);                                  
  } else if(rsmd.getColumnType(i)==java.sql.Types.TIMESTAMP){
      csv = csv+rs.getTimestamp(column_name);                                  
  }else{
      csv = csv+rs.getObject(column_name);                                  
  }
}
csv = csv+"]";                                  
l.Add(csv);

This code here
B4X:
  } else if(rsmd.getColumnType(i)==java.sql.Types.DOUBLE){
        app.Log("col:"+column_name+"/"+rs.getDouble(column_name));                              
      csv = csv+rs.getDouble(column_name);
give the following log-output in the b4a ide
col:Invoice Number/4736.0

Why does
B4X:
rs.getDouble(column_name)
return 4736 instead of 4736.0
 
Top