I have created a connection with Mysql and java program via jdbc. Now I want to populate the tables in the mysql database. How do I parse the data into the tables from the java
You can use the LOAD DATA INFILE SQL command.
An easy solution: read a single line an use the content as a part of an SQL INSERT command:
List<String> lines = getAllLinesFromFile(file);
for (String line: lines) {
String query = "INSERT INTO \"TABLE\" (COL1, ..., COL9) VALUES("+line+");";
stmt.executeUpdate(query);
}
Replace TABLE
with your actual tablename and COL1, ..., COL9
with an enumeration of your column names. There may be solutions with a better database performance (like using prepared statements) but the algorithm is easy and sufficient to get some data into the database.