Basically I have (ignoring exception handling, etc.):
connection.setAutoCommit(false);
Statement statement1 = connection.createStatement();
statement1.executeUpdate("...");
statement1.close();
Statement statement2 = connection.createStatement();
statement2.executeUpdate("...");
statement2.close();
connection.commit();
If I understand correctly it shouldn’t have any impact because all it really does is free the resources for the GC. Especially with Derby: You should explicitly close Statements, ResultSets, and Connections when you no longer need them. Connections to Derby are resources external to an application, and the garbage collector will not close them automatically.
However will it cause any issues with the transaction? I don’t believe the transaction relies on the Statement. Can anyone please confirm this?
Absolutely, you can close them, and you should.