Please post full PolaczZBaza class. Anyway, statement may be null. In this case, we are creating this construction:
void closeResources(PreparedStatement statement, ResultSet resultSet, Connection connection) {
if(statement != null) try { statement.close(); } catch (SQLException) { //log..}
if(resultSet!= null) try { resultSet.close(); } catch (SQLException) { //log..}
if(connection!= null) try { connection.close(); } catch (SQLException) { //log..}
}
it is null pointer safe and catching exception makes sure that all resources will be closed anyway.