This has nothing to do with Java: database type char(length)
is used to specify fixed-length strings, which are padded with whitespace on retrieval to the desired length when the data stored in them has fewer characters than is specified at the definition.
To address this problem, use a data type that is appropriate for variable-length strings, i.e. a varchar
, nvarchar
, or text
:
CREATE TABLE Customers(
name nvarchar(15)
, lname nvarchar(15)
, adress nvarchar(15)
)