chaitu chaitu
asked on
upload the csv file those records should be inserted corresponding fields of the table in the dabatase
i have a csv file in that i have id and name columns and the corresponding values below that.my requirement is i will upload that csv file those records should be inserted corresponding fields of the table in the dabatase.how will i do this?
Some dbs can load CSV automatically btw
ASKER
through java i have to do this
I'd use the above with a PreparedStatement in batch mode
ASKER
just tell me a psecudo code how to read csv file using CSVParser
ASKER
ur talking abt this;but here how will u pass cvs file??
String[][] values = CSVParser.parse(new StringReader(""));
// Display the parsed data
for (int i=0; i<values.length; i++){
for (int j=0; j<values[i].length; j++){
System.out.println(values[ i][j]);
}
System.out.println("-----" );
}
String[][] values = CSVParser.parse(new StringReader(""));
// Display the parsed data
for (int i=0; i<values.length; i++){
for (int j=0; j<values[i].length; j++){
System.out.println(values[
}
System.out.println("-----"
}
>>how will u pass cvs file??
You don't pass the CVS file. You insert individual values in that array into the DB
You don't pass the CVS file. You insert individual values in that array into the DB
ASKER
String[][] values = CSVParser.parse(new FileReader(new File("c:/chaitu/emp.csv")) );
// Display the parsed data
for (int i=0; i<values.length; i++){
for (int j=0; j<values[i].length; j++){
System.out.println(values[ i][j]);
}
System.out.println("-----" );
}
in the emp.csv file i have id and name values will be stored.......
// Display the parsed data
for (int i=0; i<values.length; i++){
for (int j=0; j<values[i].length; j++){
System.out.println(values[
}
System.out.println("-----"
}
in the emp.csv file i have id and name values will be stored.......
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
(If 'id' is not a String, obviously make the appropriate adjustments)
ASKER
so what i am doing is correct
String[][] values = CSVParser.parse(new FileReader(new File("c:/chaitu/emp.csv")) );
String[][] values = CSVParser.parse(new FileReader(new File("c:/chaitu/emp.csv"))
Yes
:-)
http://ostermiller.org/utils/CSV.html