将CSV文件作为数据库表读取到Java中 [英] Reading a CSV file into Java as a DB table

查看:106
本文介绍了将CSV文件作为数据库表读取到Java中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现许多关于使用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.

推荐答案

您可以使用 HSQL 来执行它,请参见 docs

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屋!

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