Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2011
    Posts
    4

    Unanswered: 'INSERT INTO' AES_ENCRYPT problem

    Hi, I am trying an INSERT INTO statement in my java program.

    The query is for a user to create an account, input a username and password and that should save to the MySQL database. I obviously don't what the passwords to be shown in the database.

    Here is the query: -

    "INSERT INTO accounts (username, password) VALUES (?, AES_ENCRYPT(?, 'key'))");

    I seem to be getting errors:

    ERROR: Data truncation: Data too long for column 'password' at row 1

  2. #2
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    How many characters does the AES_ENCRYPT return and what is your definition in the table? Are you sure that the data will fit into the field? The AES_ENCRYPT returns a string length defined by the following formula: 16 * (trunc(string_length / 16) + 1)
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

  3. #3
    Join Date
    Mar 2011
    Posts
    4
    Quote Originally Posted by it-iss.com View Post
    How many characters does the AES_ENCRYPT return and what is your definition in the table? Are you sure that the data will fit into the field? The AES_ENCRYPT returns a string length defined by the following formula: 16 * (trunc(string_length / 16) + 1)
    Thanks, working now, the data length was too short, I put the length as 15.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •