Countries

Report a typo

Given the following code:

String insertCountriesSQL = "INSERT INTO countries " +  "(id, name, capital) VALUES (?, ?, ?)";

try (Connection con = dataSource.getConnection()) {

    con.setAutoCommit(false);

    Savepoint savepoint0 = con.setSavepoint();

    try (PreparedStatement insertCountries = con.prepareStatement(insertCountriesSQL)) {

        insertCountries.setInt(1, 1);
        insertCountries.setString(2, "Spain");
        insertCountries.setString(3, "Madrid");
        insertCountries.executeUpdate();

        Savepoint savepoint1 = con.setSavepoint();

        insertCountries.setInt(1, 2);
        insertCountries.setString(2, "England");
        insertCountries.setString(3, "London");
        insertCountries.executeUpdate();

        Savepoint savepoint2 = con.setSavepoint();

        insertCountries.setInt(1, 3);
        insertCountries.setString(2, "Italy");
        insertCountries.setString(3, "Rome");
        insertCountries.executeUpdate();

        con.rollback(savepoint1);
        con.rollback(savepoint2);

        con.commit();

    } catch (SQLException e) {
        e.printStackTrace();
        con.rollback(savepoint0);
    }
} catch (SQLException e) {
    e.printStackTrace();
}

Which countries will be added to the table?

Select one option from the list
___

Create a free account to access the full topic