Пример #1
0
 /** Runs a user-interface and closes */
 public void runInterface() {
   Announce.message("Connected to", this);
   while (true) {
     D.p(
         "Enter an SQL query (possibly of multiple lines), followed by a blank line (or just a blank line to quit):");
     StringBuilder sql = new StringBuilder();
     String s;
     while ((s = D.r()).length() != 0) sql.append(s).append("\n");
     if (sql.length() == 0) break;
     sql.setLength(sql.length() - 1);
     Announce.doing("Querying database");
     if (sql.length() == 0) break;
     try {
       ResultSet result = query(sql.toString());
       Announce.done();
       if (result != null) D.p(describe(result, 50));
     } catch (SQLException e) {
       Announce.failed();
       e.printStackTrace(System.err);
       Announce.message("\n\n... but don't give up, try again!");
     }
   }
   Announce.doing("Closing database");
   close();
   Announce.done();
 }