I need your help in inserting each value in the list
private List<String> selectedCertificate = new ArrayList<String>();
The selected certificate will have the values ["A","B","C"] and I want to insert each item in a separate row for the same id (ex.50)
Record No.1 50 A Record No.1 50 B Record No.1 50 C
Connection dbConnection = null;
PreparedStatement preparedStatement = null;
String insertTableSQL = "INSERT INTO temp"
+ "(USER_ID, Certificate_Code) VALUES"
+ "(?,?)";
try {
dbConnection = getDBConnection();
preparedStatement = dbConnection.prepareStatement(insertTableSQL);
preparedStatement.setInt(1, 50);
preparedStatement.setString(2, selectedCertificate);
// execute insert SQL stetement
preparedStatement.executeUpdate();
System.out.println("Record is inserted");
} catch (SQLException e) {
System.out.println(e.getMessage());
}
Will this will help:
(String certificate: certificates)
{
preparedStatement.setInt(1, 50);
preparedStatement.setString(2, selectedCertificate);
}