2
votes

In my app, I:

  • let Hibernate create H2 DB
  • populate DB through JDBC SQL statement with CSV import (INSERT INTO ... SELECT ... FROM CSVREAD(file.csv)). File is in UTF-8 encoding.

On Linux special characters in the DB are correct.

On Windows (default encoding cp1250) special characters are incorrect.

When I try different CSV file encoding (cp1250, iso-8859-2), it works on Windows, but not on Linux.

Is there any way to tell H2 it needs to respect UTF-8 encoding on Windows?

1
Are you using Eclipse? By default, Java projects in Eclipse in Windows use a different encoding. Changing it to UTF8 in the project preferences may solve your problem.Igor Rodriguez
How did you use CSVREAD exactly? Did you use CSVREAD('file.csv', null, 'charset=UTF-8') as documented?Thomas Mueller
Thanks Thomas, it worked. I searched only in functions help page, not grammar.dunadan
@dunadan Thanks! I have added an answer.Thomas Mueller

1 Answers

3
votes

UTF-8 needs to be set in the options parameter of the CSVREAD function, as follows:

CSVREAD('file.csv', null, 'charset=UTF-8')