1

我有以下连接到 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");

我对这个完全不知所措!

4

1 回答 1

2

这个线程来看, Postgres 不支持这种语句中的绑定参数。

于 2018-12-10T05:59:46.667 回答