Java examples for JDBC:ResultSet
Inserting a Row into a Database Table Using an Updatable Result Set
import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class Main { public static void main(String[] argv) { try { Connection connection = null; Statement stmt = connection.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet resultSet = stmt.executeQuery("SELECT * FROM my_table"); // Move cursor to the "insert row" resultSet.moveToInsertRow(); // Set values for the new row. resultSet.updateString("col_string", "new data"); // Insert the row resultSet.insertRow(); } catch (SQLException e) { } } }