JDBC - (Insert|Update) DML Statament


DML statement in JDBC

Retrieving key

The Statement method executeUpdate is called with two parameters, the first is the SQL statement to be executed, the second is an array of String containing the column name that should be returned when getGeneratedKeys is called.

Retrieving a named column using executeUpdate and getGeneratedKeys

String keyColumn[] = {"ORDER_ID"};
Statement stmt = conn.createStatement();
int rows = stmt.executeUpdate("INSERT INTO ORDERS " +
"VALUES (966431502, ’BILLG’)",
ResultSet rs = stmt.getGeneratedKeys();

Powered by ComboStrap