将数据从文件解析为Java,然后解析为mysql数据库 [英] data parsing from a file into java and then into a mysql database

查看:186
本文介绍了将数据从文件解析为Java,然后解析为mysql数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有上述格式的.Data文件.我正在用Java编写程序,该程序将从.data文件中获取值并将其放在缓冲区中.我的Java程序通过JDBC连接到Mysql(windows).因此,我需要从上述格式的文件中读取值,并将其放入

I have .Data file given in the above format . I am writing a program in java that will take the values from the .data file and put it in the buffer. MY java program is connected to Mysql(windows) via JDBC. So I need to read the values from the file given in the above format and put it the buffer like

Insert Into building values ("--", "---",----) 

通过这种方式,我存储了这些值,并且jdbc将在Mysql(windows)上填充数据库表.请告诉我最好的方法.

In this way, i store these values and jdbc will populate the database tables on Mysql(windows). Please tell me teh best way.

推荐答案

查看

Check out the answers to this question for reading file lines and splitting them into chunks. I know the question says Groovy: but most answers are Java. Then insert the values you retrieved via JDBC.

实际上,由于您的数据文件显然是CSV,因此您也可以使用CSV库,例如 OpenCSV 来读取值.

Actually, since your data file is obviously CSV, you could also use a CSV libary like OpenCSV to read the values.

这篇关于将数据从文件解析为Java,然后解析为mysql数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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