Join the Stack Overflow Community
Stack Overflow is a community of 6.4 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

So I have this script that i need to execute from a Java web application. The file containing this lines is located under 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.

Any ideas

share|improve this question
    
In PostgreSQL, when you use the COPY command (not the \copy command from psql), it is looking for files on the server that runs PostgreSQL, not on the client side. Is your web application running on the same machine as PostgreSQL? – RealSkeptic yesterday
    
yes. it is the same machine always. – user2960896 yesterday
    
Then you need to specify the full path of the csv file, and also make sure that the hierarchy of folders and the file itself are readable by the user account that runs PostgreSQL. – RealSkeptic yesterday
    
Understood. Thanks. – user2960896 yesterday

To my understanding, the SQL query is running on the server, which is a separate filesystem to the client running the web application.

The sql server would be looking for a file on the server, while the CSV file is actually located on the client's machine.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.