问题描述
我想从网络应用程序(Tomcat 5.5.x)中读取CSV文件,我得到的是FileNotFoundExceptions的:
dbStatement.executeQuery(SELECT * FROM CSVREAD('csvfile.csv'););
我不认为我可以/需要指定绝对路径Linux / Tomcat服务器我将无法访问)和不确定的文件协议必需('jar:file',classpath:等)。
在** / WEB-INF / classes / csvfile.csv下
我需要传递给CSVREAD()的路径结构的任何想法?
感谢
Rich
也许你可以尝试动态构建查询,首先使用 ServletContext.getRealPath(/ WEB-INF / classes / csvfile.csv)检索完整路径
I'm trying to read a CSV file from within a web application (Tomcat 5.5.x) and all I get is 'FileNotFoundExceptions's:
dbStatement.executeQuery("SELECT * FROM CSVREAD('csvfile.csv');");
I don't think I can/need to specify an absolute path (it will be deployed into a Linux/Tomcat server I won't have access to) and am unsure of the file protocol necessary ('jar:file', classpath: etc).
The file is under "**/WEB-INF/classes/csvfile.csv"
Any ideas on the structure of the path I need to pass to CSVREAD()?
Thanks
Rich
Maybe you could try to dynamically build the query, first retrieving the full path with ServletContext.getRealPath("/WEB-INF/classes/csvfile.csv")
.
这篇关于如何使用H2的CSVREAD()函数/查询访问WAR中的CSV文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!