1.数据库表
CREATE TABLE test_table (
id bigserial NOT NULL,
test_key text NOT NULL DEFAULT ''::text,
content text NOT NULL DEFAULT ''::text
);
2.上传文件方式
public class Test{
private static final String delimiter = ",";
public static void main(String[] args) {
new Test().copy("test_table", "/home/user/text.csv");
}
public void copy(String tabName, String filePath){
Connection connection = null;
CopyManager copyManager = null;
FileReader reader = null;
try {
long start = System.currentTimeMillis();
connection = DbUtil.getConnection();
copyManager = new CopyManager((BaseConnection) connection);
reader = new FileReader(new File(filePath));
copyManager.copyIn(