Logo Search packages:      
Sourcecode: henplus version File versions  Download package

int henplus::commands::ListUserObjectsCommand::execute ( SQLSession  session,
String  cmd,
String  param 
) [inline]

execute the command given.

Implements henplus::Command.

Definition at line 65 of file ListUserObjectsCommand.java.

References henplus::Command::EXEC_FAILED, henplus::commands::ResultSetRenderer::execute(), henplus::SQLSession::getConnection(), henplus::commands::ResultSetRenderer::limitReached(), rehash(), and henplus::Command::SUCCESS.

                                                                     {
      if (cmd.equals("rehash")) {
          rehash(session);
      }
      else {
          try {
            Connection conn = session.getConnection();  // use createStmt
            DatabaseMetaData meta = conn.getMetaData();
            String catalog = conn.getCatalog();
            /**/
                HenPlus.msg().println("catalog: " + catalog);
                ResultSetRenderer catalogrenderer = 
                    new ResultSetRenderer(meta.getCatalogs(), "|", true, true,
                                          2000, HenPlus.out());
                catalogrenderer.execute();
                /**/
            ResultSetRenderer renderer;
                ResultSet rset;
                String objectType;
                int[] columnDef;
                if ("procedures".equals(cmd)) {
                    objectType = "Procecdures";
                    HenPlus.msg().println(objectType);
                    rset = meta.getProcedures(catalog, null, null);
                    columnDef = PROC_DISP_COLS;
                }
                else {
                    boolean showViews = "views".equals(cmd);
                    objectType = ((showViews) ? "Views" : "Tables");
                    HenPlus.msg().println(objectType);
                    rset = meta.getTables(catalog,
                                          null, null,
                                          (showViews)
                                          ? LIST_VIEWS
                                          : LIST_TABLES);
                    columnDef = TABLE_DISP_COLS;
                }
                
            renderer = new ResultSetRenderer(rset, "|", true, true, 2000,
                                                 HenPlus.out(),
                                     columnDef);
            int tables = renderer.execute();
            if (tables > 0) {
                HenPlus.msg().println(tables + " " + objectType + " found.");
                if (renderer.limitReached()) {
                  HenPlus.msg().println("..and probably more; reached display limit");
                }
            }
          }
          catch (Exception e) {
            HenPlus.msg().println(e.getMessage());
            return EXEC_FAILED;
          }
      }
      return SUCCESS;
    }


Generated by  Doxygen 1.6.0   Back to index