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.
For example, close a Statement object using its close method; close a Connection object using its close method. If auto-commit is disabled, active transactions need to be explicitly committed or rolled back before closing the connection