protected void closeResultSet(ResultSet rs) {
   try {
     if (rs != null) {
       rs.close();
     }
   } catch (SQLException e) {
     JDBCASEPlugin.getDefault().log(e);
   }
   try {
     if (stmt != null) stmt.close();
   } catch (SQLException e) {
     JDBCASEPlugin.getDefault().log(e);
   }
   try {
     if (oldCatalog != null) {
       conn.setCatalog(oldCatalog);
     }
   } catch (SQLException e) {
     JDBCASEPlugin.getDefault().log(e);
   }
 }
  /**
   * This is a crude implementation of GUID generator. the new name is generated using letter 'T',
   * localhost's ip address and the current timestamp plus three digit of random number, with a
   * maximum total length of 27. There're rare chances of name conflict. But even if that does
   * happen, user can always save it again.
   */
  static String makeNewName(String oldName) {
    if (_localhost == 0) {
      try {
        _localhost = Math.abs(InetAddress.getLocalHost().hashCode());
      } catch (Exception e) {
        JDBCASEPlugin.getDefault().log(e);
      }
    }
    String timeStamp = String.valueOf(Math.abs(System.currentTimeMillis()));
    int random = Math.abs(new Random().nextInt() % 1000);

    return ("T" + _localhost + timeStamp + random);
  }
 /**
  * Creates a result set to be used by the loading logic. The SQL statement is:
  *
  * <pre>
  * select c.name from syscolumns c where id = ? order by c.colid
  * </pre>
  */
 protected ResultSet createResultSet() throws SQLException {
   Table table = this.getTable();
   String query = null;
   String catalog = table.getSchema().getCatalog().getName();
   int tableId = ((ICatalogTable) table).getTableId();
   conn = ((ICatalogObject) table).getConnection();
   query = ASESQLs.QUERY_TABLE_COLUMNS;
   ResultSet rs = null;
   oldCatalog = conn.getCatalog();
   conn.setCatalog(catalog);
   stmt = conn.prepareStatement(query);
   stmt.setInt(1, tableId);
   try {
     rs = stmt.executeQuery();
   } catch (SQLException e) {
     JDBCASEPlugin.getDefault().log(e);
     throw e;
   }
   return rs;
 }