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

  • Home
  • SEARCH
  • 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 have 2 applications deployed in tomcat, I want to use in one project
I have been trying to use @Resource and @Service annotations in Spring as follows.
In grails I can set the password field to have a minimum size constraint
I can find plenty of examples that show how to configure a URL to
I have couple of servlets designed to hold its own message source, but there
a sample of json response looks like this: {publicId:123,status:null,partner:null,description:null} It would be nice to
I have a json object that is actually an arraylist of objects previously converted
I'm new to MyBatis. Ive been trying to configure mybatis in a webservice I'm
I have this in my applicationContext.xml <bean class=org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter /> <mvc:annotation-driven conversion-service=conversionService/> <bean id=conversionService class=org.springframework.context.support.ConversionServiceFactoryBean>
Javascript: var string = '(37.961523, -79.40918)'; //remove brackets: replace or regex? + remove whitespaces

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.