#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2012
    Posts
    9
    Rep Power
    0

    DataTruncation Error


    Hi,

    I am trying to insert a row in mysql database and I get this exception
    com.mysql.jdbc.MysqlDataTruncation: Data truncation: Out of range value adjusted for column.
    The datatype of the column is bigint(20) unsigned.
    And there are not more than 5 rows in the table.

    What is the cause of this error?

    Thanks
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    What value are you trying to insert into the column? The error means the data you passed for the column is not fully compatible with the column definition.

    The number of rows in the table has nothing to do with the error.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2012
    Posts
    9
    Rep Power
    0
    Its just numbers in the range of 1 to 20.
  6. #4
  7. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,118
    Rep Power
    4274
    Originally Posted by taas
    Its just numbers in the range of 1 to 20.
    in that case, BIGINT is overkill

    BIGINT requires 8 bytes and holds numbers between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807

    INTEGER requires 4 bytes and holds numbers between -2,147,483,648 and 2,147,483,647

    MEDIUMINT requires 3 bytes and holds numbers between -8,388,608 and 8,388,607

    SMALLINT requires 2 bytes and holds numbers between -32,768 and 32,767

    TINYINT requires 1 byte and holds numbers between -128 and 127

    which of these is appropriate for your data?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo