Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3980494
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:17:50+00:00 2026-05-20T05:17:50+00:00

I use Spring’s JdbcTemplate to run an insert SQL statement. The field I want

  • 0

I use Spring’s JdbcTemplate to run an insert SQL statement. The field I want to insert into is a NUMBER. The value is: -0.11111111 of type float. However, after insertion into DB, the value I get is padded with random numbers -0.1111111119389534.

Note that when I use direct JDBC, the value is inserted as it is, without the padded numbers.

I use BeanPropertySqlParameterSource and MapSqlParameterSource for setting the parameters of the INSERT statement, both giving same results. The code looks like this:

BeanPropertySqlParameterSource params = new BeanPropertySqlParameterSource(stat);
int n = jt.update(query, params);

where jt is an instant of SimpleJdbcTemplate.

The DB is Oracle.

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:17:51+00:00Added an answer on May 20, 2026 at 5:17 am

    For Java’s float datatype, Spring JDBC behaves differently than direct JDBC.

    Consider SQL statement INSERT INTO table (field) VALUES (-0.11111111) with field Oracle type NUMBER and -0.11111111 of type float.

    With direct JDBC, it gives the value of field as it is, i.e. -0.11111111.

    But with Spring JDBC (using JdbcTemplate.update(), it gives the value of field padded with numbers, i.e. -0.1111111119389534.

    No such difference occurs for Java type double. The inserted value is not padded with numbers.

    With Java datatype BigDecimal, the inserted value into DB will also be padded with numbers, i.e. -0.1111111099999999990428634077943570446223 and this is consistent for both direct JDBC and Spring JDBC.

    The results for float is understandable, as Java states in its documentation that “(Float) data type should never be used for precise values, such as currency.” So eventhough the behaviour is different in direct JDBC and Spring JDBC, we can’t say it’s wrong.

    For BigDecimal, read http://download.oracle.com/javase/6/docs/api/java/math/BigDecimal.html#BigDecimal%28double%29

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use Spring 3 for validation. In the reference documentation, section 6.2
I want to use Spring-Tiles intergration. Here you can see how my app looks
I'm trying to use Spring to inject a SLF4J logger into a class like
We use Spring's JdbcTemplate which is configured through Spring config as illustrated below. Is
I am planing to use Spring JDBCTemplate for all my database needs. I wanted
I use spring 3. I'm trying to display a value of an object in
I want to use Spring Cache features but I don't know what dependedencies this
I want to use spring with jsf in my project. So how can I
I want to use Spring inside a legacy application. The core piece is a
I want to use Spring Security, and it says to map the filter to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.