List:MySQL and Java« Previous MessageNext Message »
From:Mark Matthews Date:January 21 2003 6:47pm
Subject:Re: Possible bug in PreparedStatement.setString(int,String) ?
View as plain text  
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Luca Lafranchi wrote:
> Hi :)
> 
> If I try to save something like "       -         " into  MySQL 
> 4.0.8-gamma and 3.23.51 using a PreparedStatement, it actually trims the 
> trailing spaces (I did a select with mysql client to look at it). This 
> happens both with 2.0.14 and with latest snapshot builds. The column is 
> varchar(50).
> 
> Has anybody a clue?
> 
> Ciao
> Luca

Nope. It's a feature. See http://www.mysql.com/doc/en/CHAR.html

"However, in contrast to CHAR, VARCHAR values are stored using only as 
many characters as are needed, plus one byte to record the length. 
Values are not padded; instead, trailing spaces are removed when values 
are stored. (This space removal differs from the ANSI SQL specification.)"

	-Mark
- -- 
MySQL 2003 Users Conference -> http://www.mysql.com/events/uc2003/

For technical support contracts, visit https://order.mysql.com/?ref=mmma

     __  ___     ___ ____  __
    /  |/  /_ __/ __/ __ \/ /  Mark Matthews <mark@stripped>
   / /|_/ / // /\ \/ /_/ / /__ MySQL AB, Full-Time Developer - JDBC/Java
  /_/  /_/\_, /___/\___\_\___/ Flossmoor (Chicago), IL USA
         <___/ www.mysql.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.1.90 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+LYedtvXNTca6JD8RArSWAKCOh/aUTl7SGc9eci4gfJtrCfkhLgCeITxB
Aiqref23tu82VP14HDw1Ta8=
=Bsa+
-----END PGP SIGNATURE-----

Thread
Possible bug in PreparedStatement.setString(int,String) ?Luca Lafranchi21 Jan
  • Re: Possible bug in PreparedStatement.setString(int,String) ?Mark Matthews21 Jan
  • Re: Possible bug in PreparedStatement.setString(int,String) ?Luca Lafranchi21 Jan
    • Re: Possible bug in PreparedStatement.setString(int,String) ?Mark Matthews21 Jan
      • load file errorRemoved13 Nov
    • installation problemRemoved13 Nov
  • Re: Possible bug in PreparedStatement.setString(int,String) ?Luca Lafranchi22 Jan