Adding Rows to a Table by Using the SQL INSERT Statement
- Procedure
- Formulate a SQL INSERT string for adding rows of data to a table.
- Call the
createStatement()method of theSessionobject. Pass the SQL INSERT string as an argument. - If the SQL INSERT string contains parameter markers, call the
Statementmethods to set the parameter values. - Run the INSERT statement by calling the
executeUpdate()method of theStatementobject. - Check the result of the
executeUpdate()method to verify that the correct number of rows have been inserted into the table. - Set different parameter values and rerun the INSERT statement by repeating steps 3 to 5.
- Close the
Statementobject.