DatabaseMetaData meta = conn.getMetaData();
ResultSet rs = meta.getTables(null,userName,null,{TABLE});
rs.getString("TABLE_NAME")
把所有的table取出来,看看有你有想要的

解决方案 »

  1.   

    rs.getString("TABLE_NAME")
    有无返回值?返回的是否是个数组?
      

  2.   

    rs.getString("TABLE_NAME")
    有无返回值?返回的是否是个数组?
      

  3.   

      public static List getAllTableName(Connection cnn) throws SQLException{
      List tables = new ArrayList();   DatabaseMetaData dbMetaData = cnn.getMetaData();//   "TABLE", "VIEW", "SYSTEM TABLE", 
    //   "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM"
      String[] types = {"TABLE", "VIEW"};   ResultSet tabs = dbMetaData.getTables(null, null, null, types);
      /*ResultSet:
        TABLE_CAT   String => table catalog (may be null) 
        TABLE_SCHEM String => table schema (may be null) 
        TABLE_NAME  String => table name 
        TABLE_TYPE  String => table type. 
        REMARKS     String => explanatory comment on the table 
        TYPE_CAT    String => the types catalog (may be null) 
        TYPE_SCHEM  String => the types schema (may be null) 
        TYPE_NAME   String => type name (may be null) 
        SELF_REFERENCING_COL_NAME String => name of the designated "identifier" column of a typed table (may be null) 
        REF_GENERATION String => specifies how values in SELF_REFERENCING_COL_NAME are created. Values are "SYSTEM", "USER", "DERIVED". (may be null) 
       */
      while(tabs.next()){
      tables.add(tabs.getObject("TABLE_NAME"));   }
      System.out.println(tables);
      return tables; }