How fix `octets is too long for type Varchar for column` in vetica via jdbc

280 views Asked by At

There is a file (my_table.sql) and insert statement in it:

Insert into my_table (id, my_string) 
Values (1, 'some string with non ASCII symbols like this �');

Where I run this via jdbc it fails with ERROR: String of N octets is too long for type Varchar(X) for column my_string. And it looks like column is too short but when I run:

vsql -v AUTOCOMMIT=on  -h localhost -U dbadmin -d my_db < my_table.sql

It completes well. Why error happens? How to fix it? I have tried to add ?useUnicode=true&amp;characterEncoding=UTF-8 to jdbc connection string but this did not help.

UPDATED

Table definiton:

create table my_table
(
    id                      int,
    my_string               varchar(255)
);

comment on table my_table is 'copmment';
0

There are 0 answers