【发布时间】:2018-07-26 16:46:36
【问题描述】:
我的应用程序中有一个 neo4j 嵌入式数据库,我想加载一个 .csv 文件来填充数据库。我设法在/import 文件夹中创建了.csv 文件,但是当我尝试加载它时,我得到了Couldn't load the external resource at: file:/csv_file.csv。
我读过它可能与权限有关,但我无法更改它们,因为每次运行我的应用程序时它都会创建整个文件夹结构(我尝试在使用 Runtime.getRuntime().exec("chmod 777 /path_to_file/csv_file.csv") 创建文件后更改它们,但它永远不会起作用)
这是我的代码:
public void addCSVtoDB() {
try ( Transaction ignored = graphDb.beginTx();
Result result = graphDb.execute( "LOAD CSV WITH HEADERS FROM \"file:///csv_file.csv\" AS csvLine\n" )
{
}
我使用的是 MacOSX 10.11,所以 / 应该没问题。有什么想法吗?
【问题讨论】:
-
将此添加到您的 conf/neo4j.conf 文件 dbms.security.allow_csv_import_from_file_urls=true
-
它是嵌入的,我没有任何conf文件(我认为)
-
我已将嵌入式数据库配置为允许文件 url,仍然得到
couldn't load the external resource at: file:/csv_file.csv我正在这样做来定义数据库:graphDb = new GraphDatabaseFactory() .newEmbeddedDatabaseBuilder( databaseDirectory ) .setConfig( GraphDatabaseSettings.allow_file_urls, "true" ) .newGraphDatabase();
标签: java database macos csv neo4j