如何使用H2的CSVREAD()函数/查询访问WAR中的CSV文件? [英] How to access CSV file within WAR using H2's CSVREAD() function/query?

查看:166
本文介绍了如何使用H2的CSVREAD()函数/查询访问WAR中的CSV文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从网络应用程序(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文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆