【发布时间】:2018-12-09 03:42:13
【问题描述】:
我有以下连接到 PostgreSQL 数据库的接口:
public interface ExampleDAO extends JpaRepository<Example, Integer>
{
@Modifying
@Query(value="COPY my_table FROM :filename CSV HEADER", nativeQuery=true)
public int copyMyTable(@Param("filename") String filename);
}
但是当我运行它时,我得到了
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute statement
我删除了@Param 并将文件名硬编码,它工作正常。传递的文件名是:
copyMyTable("C:\\path\\to\\my\\file.csv");
我对这个完全不知所措!
【问题讨论】:
标签: postgresql file csv spring-data-jpa sqlbulkcopy