ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/owl/tags/aglappe-0.6/tools/MySQLConnection.java
(Generate patch)
# Line 483 | Line 483
483      }
484      
485      /**
486 +     * To get all tables for this MySQLConnection's database.
487 +     * @return an array of String with all table names
488 +     */
489 +        public String[] getTables4Db(){
490 +                String[] tables=null;
491 +                ArrayList<String> tablesAL=new ArrayList<String>();
492 +                String query="SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='"+dbname+"' ORDER BY TABLE_NAME DESC;";
493 +                try {                  
494 +                        Statement S = this.conn.createStatement();
495 +                        ResultSet R=S.executeQuery(query);
496 +                        while (R.next()){
497 +                                tablesAL.add(R.getString(1));
498 +                        }
499 +                        S.close();
500 +                        R.close();
501 +                        conn.close();
502 +                        tables=new String[tablesAL.size()];
503 +                        for (int i=0;i<tablesAL.size();i++) {
504 +                                tables[i]=tablesAL.get(i);
505 +                        }
506 +                }
507 +                catch(SQLException e){                  
508 +                        System.err.println("Couldn't get table names from "+host+" for db="+dbname);
509 +            System.err.println("SQLException: " + e.getMessage());
510 +            System.err.println("SQLState:     " + e.getSQLState());
511 +            System.err.println("VendorError:  " + e.getErrorCode());
512 +                        e.printStackTrace();
513 +                }
514 +                return tables;
515 +        }
516 +
517 +    /**
518       * To set the sql_mode of this connection.
519       * @param sqlmode either NO_UNSIGNED_SUBTRACTION or blank
520       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines