How to read a file and add its content to database?
I have a text file called patientlist which looks like:
george 19 180 75
paul 20 182 84
laura 21 176 73
What I want to do is to read this file and add the lines to a table in
mysql database. I have written this code that reads the file:
public static void patients() throws IOException{
try {
in= new BufferedReader(new FileReader(new File("patientlist.txt")));
}
catch (FileNotFoundException e) {System.out.println("There was a
problem: " + e);}
while((read = in.readLine()) != null){
System.out.println(read);
}
}
"read" is the values from the file. I want to insert these values to my
table in my database which has the parameters(name, age, height, weight)
the 4 values on each line. I couldn't find out how to seperate the values
on a line. Because I want george, paul and laura to be under the parameter
of name at the database etc. so I can use select in future? Thanks for the
help!
No comments:
Post a Comment