I have to **inserts 100s of rows**
into the database such as all the column values are exactly same except one. For example sake consider a table
------------------
|UserId|Timestamp|
------------------
Now **only timestamp is changing for every insert**
.
Is it advisable to use prepared statement in the following way ?
PreparedStatement pstmt = con.prepareStatement("INSERT INTO Pings (UserId,Timestamp) VALUES (?,?)";
pstmt.setInt(1,001); //setting user is
while(true){
pstmt.setTimestamp(2,getTimestamp());
pstmt.executeUpdate();
}
Compared to
while(true){
pstmt.setInt(1,001);
pstmt.setTimestamp(2,getTimestamp());
pstmt.executeUpdate();
}
Will first approach work given that I am setting 1st column value only once ?