问题描述
我有上述格式的.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.
推荐答案
查看,用于读取文件行并将其拆分为大块.我知道问题是Groovy的:但是大多数答案是Java.然后插入您通过JDBC检索到的值.
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数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!