HSQLDB挂载中文CSV

HSQLDB可以在创建表格之后,通过挂载csv文件来导入数据。HSQLDB默认编码是ASCII,在导入UTF-8的表格时候出现了乱码。解决方法:

  1. csv用sublime等工具存储为utf-8(确保格式一致)
  2. hsqldb命令指定encoding=utf-8
    如下:
drop table student IF EXISTS;
Create Text table student ( 
 stu_id char(10) primary key, 
 name varchar(20), 
 dept varchar(20),
 class varchar(20),
 stu_type varchar(20),
 email varchar(50),
 tel char(11));
SET TABLE student SOURCE "xueshengmingdan.csv;fs=,;encoding=UTF-8";
select * from student;

官方文档如下:

The character encoding for the source file is ASCII by default, which corresponds to the 8-bit ANSI character set. To support UNICODE or source files prepared with different encodings this can be changed to UTF-8 or any other encoding. The default is encoding=ASCII and the option encoding=UTF-8 or other supported encodings can be used. From version 2.3.4, the two-byte-per-character encodings of UTF-16 are also supported. The encoding=UTF-16BE is big-endian, while encoding=UTF-16LE is little-endian. The encoding=UTF-16 is big-endian by default. This encoding reads a special Unicode character called BOM if it is present at the beginning of an existing file and if this character indicates little-endian, the file is treated as such. Note HSQLDB does not write a BOM character to the files it creates from scratch.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值