将CSV文件作为数据库表读取到Java中 [英] Reading a CSV file into Java as a DB table
问题描述
我发现许多关于使用Java读取CSV的帖子,而他们所指向的API在读取CSV文件时都采用了面向行的方法.类似于在获得一行时,获取每一列的值".
I've found numerous posts about reading CSV with Java and the APIs they were pointing at all had a line-oriented approach when it came to reading a CSV file. Something like "while you get a line, get the values of every column".
我希望使用更高级别的API,例如在Perl中,DBI允许您在CSV上使用SQL,就像在DB表中一样.否则,我将不得不自己实现许多访问逻辑.
I'd appreciate a higher-level API, like in Perl where DBI allows you to use SQL on CSV like if it where a DB table. Otherwise I'll have to implement lots of access logic by myself.
是否有这样的API?我想念什么吗?有一些关于JDBC驱动程序的参考,但是大多数是最近5年未更新的项目.
Is there such an API? Am I missing something? There are some references about JDBC drivers but most are projects that haven't been updated the last 5 years.
推荐答案
You can use HSQL in order to do it, see the following links from the docs and a blog post describing exactly that.
这篇关于将CSV文件作为数据库表读取到Java中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!