如何从Java中的Access数据库导出表并将其保存到.csv [英] How to export and save tables to .csv from access database in java
本文介绍了如何从Java中的Access数据库导出表并将其保存到.csv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用jdbc:odbc桥从带有Java的MS Access数据库中导出很多大表.我想先将这些表保存到CSV文件,但我想知道这样做的最佳方法是什么?任何帮助将不胜感激.
I am trying to export a lot of large tables from a MS Access db with java using the jdbc:odbc bridge. I wanted to save these tables to a CSV file first was wondering what would the best way to do this would be? any help would be appreciated.
推荐答案
获取值并逐行分隔值来编写标准文本文件.我确定为此目的有一些库
Fetch the values and write a standard text file line by line separating the values. I#m sure there are some libs for this purpose
try
{
FileWriter writer = new FileWriter("c:\\temp\\MyFile.csv");
while(result.next())
{
for(int i = 0; i < columnSize; i++)
{
writer.append(result.getObject(i));
if(i < columnSize - 1)
writer.append(',');
}
writer.append('\n');
}
}
catch(Exception e)
{
e.printStackTrace();
}
这篇关于如何从Java中的Access数据库导出表并将其保存到.csv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文