0

My work doing some processes like

  • Load data from csv to MySQL(migration replica table - From MSSQL)
  • read MySQL data to make a VO Java class
  • When VO edited, will save to MySQL(another table)

The problem is ...

  • open the CSV file, I can see special character ^@
  • After LOAD DATA Then do SELECT query, the data does not contains ^@
  • However, I read same data via Java and restore to another table It store \u0000

How to remove this \^0000 ?

The best solution in my current situation, I would like to handle in java code...

FYI,

  • MSSQL dump made on Windows OS (From Client)
  • MySQL Load data on Windows (Local dev environment)
  • The program which perform migration is on CentOS(Server)
Juneyoung Oh
  • 7,318
  • 16
  • 73
  • 121
  • https://stackoverflow.com/questions/12195628/understanding-the-difference-between-null-and-u000-in-java – Alex Jan 15 '18 at 09:57

1 Answers1

0

I believe your export is dumping BIT values as actual "bit characters", i.e the BIT 0 becomes \0 and the BIT 1 becomes \1.

For convenience (and speed) you could probably parse the CSV using univocity-parsers with this setting:

CsvParserSettings parserSettings = new CsvParserSettings();
parserSettings.setSkipBitsAsWhitespace(false); //prevents treating \0 and \1 as blank space

CsvParser parser = new CsvParser(parserSettings);

You can then proceed to replace \0 and \1 to characters 0 and 1 respectively on the columns where they appear.

Hope this helps.

Jeronimo Backes
  • 6,141
  • 2
  • 25
  • 29