DatabaseMetaData.getTables() with Oracle 8i thin driver
4 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Tuesday, November 27, 2001 11:29 AM


I am trying to check if a table exists on a Oracle 8i database using DatabaseMetaData.getTables().


ResultSet queryResultSet = dbMetaData.getTables(null, null, tableName, null);


However this always results in no ResultSet even when the table actually exists.


I am using Oracle 8i thin driver(o8ithin.jar). Any idea what the problem could be?

Re: DatabaseMetaData.getTables() with Oracle 8i thin driver

Posted By:   Anonymous  
Posted On:   Wednesday, November 28, 2001 01:05 PM

In addition to the other answers and in addition to case sensitivity ( which can be determined by the various storesXXX methods ), the table name is actually a tableNamePattern. Try adding "%" ( not in quotes ) to the end of your table name.

Re: DatabaseMetaData.getTables() with Oracle 8i thin driver

Posted By:   Bernie_Acs  
Posted On:   Tuesday, November 27, 2001 01:22 PM

Tables are also "case-sensitive" by default (UPPER), I failed to mention that as a potential point of failure in my previous list of possiblities...

Re: DatabaseMetaData.getTables() with Oracle 8i thin driver

Posted By:   Bernie_Acs  
Posted On:   Tuesday, November 27, 2001 12:48 PM

Here is the deal more than likely,
  • the owner of the table you are after is a differnet account than the account your application is connecting to the DB as.

  • Select premission on the table you want have not been granted to the account your application is connecting the db as.

  • A public or private synonym does not exists in the database which would allow you current account to reference the table without identifing the tables owner.



  • What these 3 points all lead to is that the owner of the table object and account being used by java app are different and no masking has been set up to allow your connection account to reference the table with out prefixing the table name with and owner id.


    To fix this you could include the owner name in the second argument of the method getTables() or create private or public synonym in the DB account your java app is connecting as to take care of the name resolution for you.


    getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types)

    Re: DatabaseMetaData.getTables() with Oracle 8i thin driver

    Posted By:   Anonymous  
    Posted On:   Tuesday, November 27, 2001 11:54 AM

    Why not run the following query to check if the table exists:


    select count(*) from sys.tab where tname =
    About | Sitemap | Contact