Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Getting MetaData for JDBC tables with getTables() does not work?

Re: Getting MetaData for JDBC tables with getTables() does not work?

From: Joe Weinstein <joeNOSPAM_at_bea.com>
Date: Wed, 26 Jan 2005 14:53:40 -0800
Message-ID: <41F81F74.5050503@bea.com>

Thomas Hansen wrote:

> When I access an Oracle database I can successfully select rows from a database
> table. So at least one table must exist. But when I try to
> access the MetaData with getTables() I get no data. Why?
>
> I use the follwoing coding:
>
> String dbname = "MYDB.TABLEA";
> DatabaseMetaData md = cn.getMetaData();
> ResultSet rsm = md.getTables(null, null, dbname, null);
> if (rsm.next()) {
> res = true;
> System.out.println("tables found"); }
> else
> System.out.println("tables not found");
>
> For what are the 4 parameters of getTables? I found some samples with
> percentage signs as values. Others filled the last paramter and left the third
> parameter to null. From my point of view putting null into parm 1 and 2
> should return ALL tables for all users. Is this correct?

     catalog - a catalog name; "" retrieves those without a catalog;
               null means drop catalog name from the selection criteria
     schemaPattern - a schema name pattern; "" retrieves those without a schema
     tableNamePattern - a table name pattern
     types - a list of table types to include; null returns all types

I would try setting the second parameter to this pattern: "%". The specs do not list null as an option for the second parameter. Also, the table name you are giving includes the dbms name, and table name. Try:

ResultSet rsm = md.getTables(null, "%", "TABLEA", null);

I hope this helps,
Joe Weinstein at BEA

>
>
> Thomas
>
Received on Wed Jan 26 2005 - 16:53:40 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US