I have a list of row object wherein each row has some fields something like this
myList= [ shridhar, 1234, 2015-10-30 3:44 , someMessage, 8;
sahil,4534, 2015-10-29 13:44 , someMessage, 18;
shubham, 3234, 2015-10-10 12:24 , someMessage, 9]
I want the list data to store it in MySql database with different fields, I'm stuck in how to set the multiple values while querying, as I'm making use of setString()
of PreparedStatement
class method which takes only two arguments.
I have tried something like this:
String query= "INSERT INTO facebooktable(name, id, date, msg, score)" + "VALUES( ?,?,?,?,?)";
PreparedStatement preStatement= connection.prepareStatement(query);
for(int index=0; index<=myList.size();index++){
rowObj=myList.get(index);
preStatement.setString() // allows only two parameters
}
How do I pass multiple values making use of the PreparedStatement
class?