db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "fabio_patricio" <fabio_patri...@terra.com.br>
Subject Problem with decimal precision
Date Wed, 02 Mar 2005 18:25:49 GMT
  Hi,

  I have a field decimal(10,2) where I insert "32,78", but when I go
to look at in the table the inserted value was "32,77", alguem which
the problem?

  My code:

    try {
        // Prepare a statement to insert a record
        String sql = "INSERT INTO TESTE_DECIMAL (VALOR_DECIMAL,
VALOR_DOUBLE) VALUES(?,?)";
        PreparedStatement pstmt = conexao.prepareStatement(sql);
    
        // Insert 10 rows
        for (int i=0; i<10; i++) {
            // Set the value
            pstmt.setDouble(1, new Double("32.78").doubleValue());
            pstmt.setDouble(2, new Double("2324234.69").doubleValue());
    
            // Insert the row
            pstmt.executeUpdate();
        }
        conexao.commit();
    } catch (SQLException e) {
        e.printStackTrace();
    }


  Best Regards.

  Fabio Patricio


Mime
View raw message