If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > 'INSERT INTO' AES_ENCRYPT problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-24-11, 10:24
RiskyShenanigan RiskyShenanigan is offline
Registered User
 
Join Date: Mar 2011
Posts: 4
'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
Reply With Quote
  #2 (permalink)  
Old 03-24-11, 11:00
it-iss.com it-iss.com is offline
Registered User
 
Join Date: Sep 2009
Location: San Sebastian, Spain
Posts: 623
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
Senior Oracle/MySQL DBA
http://www.it-iss.com
Reply With Quote
  #3 (permalink)  
Old 03-24-11, 11:13
RiskyShenanigan RiskyShenanigan is offline
Registered User
 
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On