简体   繁体   English

使用postgres脚本从JAVA导入CSV

[英]CSV import from JAVA using postgres script

So I have this script that i need to execute from a Java web application. 因此,我具有需要从Java Web应用程序执行的脚本。 The file containing this lines is located under WEB-INF 包含此行的文件位于WEB-INF下

    truncate table amm.mm_dosage_unit;
    alter table amm.mm_dosage_unit add column code_new_version character varying(1);
    copy amm.mm_dosage_unit FROM 'code_list.csv' DELIMITER ',' CSV;

I use reader to execute each of the lines. 我使用阅读器执行每一行。 Problem is that I dont know how to scpecifie the correct path for my .csv file and i get No such file or directory error. 问题是我不知道如何为我的.csv文件指定正确的路径,而我却No such file or directory得到No such file or directory错误。

Any ideas 有任何想法吗

To my understanding, the SQL query is running on the server, which is a separate filesystem to the client running the web application. 据我了解,SQL查询正在服务器上运行,这是运行Web应用程序的客户端的独立文件系统。

The sql server would be looking for a file on the server, while the CSV file is actually located on the client's machine. sql服务器将在服务器上寻找文件,而CSV文件实际上位于客户端计算机上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM