code: private void cleanConnectionClose(Connection connection, Statement stmt) {
          try {
              // clean close
              if (connection != null) {
                  connection.rollback();
              }
  
              if (stmt != null) {
                  stmt.close();
              }
  
              if (connection != null) {
                  connection.close();
              }
          } catch (SQLException e1) {
              e1.printStackTrace();
          }
      }
docs: Close connection and sql statement in a clean way.
  
  @param connection    Connection to close.
  @param stmt          Statement to close.