ResultSet on DatabaseMetaData

ResultSet on DatabaseMetaData

Post by Thomas Mangol » Mon, 24 Sep 2001 04:15:54



Hi,

I'm trying to fetch the tablenames out of e Database.
Because I want to run the application with different
DBMS and I only want to read as less as possible out of
a property-file, I try to read the DatabaseMetaData so follows:

ResultSet rs = dmd.getTables(null, null, "",
                                            new String[] {"TABLE", "VIEW",
"SYNONYM"});
ResultSetMetaData rsmd = rs.getMetaData();
ArrayList alNames = new ArrayList();  // Collection for the Tablenames
/* fetching the Name of the Column on the current DBMS containing the
tablenames
 * from the property-file */
String strColName = props.getProperty("table.tablenames");
for (int i = 1; i <= rsmd.getColumnCount(); i++) {
    if (strColName.equals(rsmd.getColumnName(i))) {
        while (rs.next())
            alNames.add(rs.getString(i));
        break;
    } // if

Quote:} // for

The problem is, there are no rows in the ResultSet rs even when i hit the
column-name from the properies in the ResultSetMetaDates. This shows,
that the connection works.
Does anybody know the problem or see where I made a mistake?

Thanks
Thomas Mangold

 
 
 

ResultSet on DatabaseMetaData

Post by Lee Fesperma » Mon, 24 Sep 2001 05:22:15



> I'm trying to fetch the tablenames out of e Database.
> Because I want to run the application with different
> DBMS and I only want to read as less as possible out of
> a property-file, I try to read the DatabaseMetaData so follows:

> ResultSet rs = dmd.getTables(null, null, "",
>                                             new String[] {"TABLE", "VIEW",
> "SYNONYM"});
> ...

> The problem is, there are no rows in the ResultSet rs even when i hit the
> column-name from the properies in the ResultSetMetaDates. This shows,
> that the connection works.
> Does anybody know the problem or see where I made a mistake?

Try null or "%" for the 3rd argument ... table name pattern.

--
Lee Fe*an, FFE Software, Inc. (http://www.veryComputer.com/)
===================================================================
* Check out Database Debunkings (http://www.veryComputer.com/)
* "Where Persistent Prevailing Database Fallacies Are Dispelled"

 
 
 

ResultSet on DatabaseMetaData

Post by Rene Pijlma » Mon, 24 Sep 2001 05:40:11


[DatabaseMetaData.getTables()]

Quote:>Try null or "%" for the 3rd argument ... table name pattern.

Null is correct. "%" is a wild guess.

--

Hoe kun je het beste hulp vragen bij computerproblemen?
http://www.leren.nl/usenet/help/

 
 
 

ResultSet on DatabaseMetaData

Post by Lee Fesperma » Mon, 24 Sep 2001 11:48:00




> [DatabaseMetaData.getTables()]
> >Try null or "%" for the 3rd argument ... table name pattern.

> Null is correct. "%" is a wild guess.

Not a guess. The tableNamePattern parameter for getTables() takes a 'like' pattern. "%"
indicates match all. Read the javadocs.

--
Lee Fe*an, FFE Software, Inc. (http://www.veryComputer.com/)
===================================================================
* Check out Database Debunkings (http://www.veryComputer.com/)
* "Where Persistent Prevailing Database Fallacies Are Dispelled"

 
 
 

ResultSet on DatabaseMetaData

Post by Rene Pijlma » Mon, 24 Sep 2001 18:59:49


Lee Fe*an schreef:


>> Null is correct. "%" is a wild guess.

>Not a guess. The tableNamePattern parameter for getTables() takes a 'like' pattern. "%"
>indicates match all. Read the javadocs.

You're right. I overlooked the reference to the "String Patters as
Arguments" section in the JDBC book.

--

 
 
 

1. databasemetadata return a null resultset

Hi,

I'm trying to acces to the databaseMetaData interface.
my code is the follwing :

   DatabaseMetaData dmd = connMZ.getMetaData();
   String tableName = "emp";
   rs2 = dmd.getColumns(null,null, tableName, null);
   while (rs2.next()) {
         System.err.println (rs2.getString(1));
   }

the result is that the rs2 is always empty.
I've tried of function such as getCatalogs, getTables... but it's still the
same.
I'm connecting on an Oracle 7.3.4 database
Any help is welcome
Thanx
Cyril

2. SQL Server Performance

3. resultset.first() and resultset.getFetchSize() not working

4. click() doesnt?

5. multiple resultsets into 1 resultset ???

6. Paradox 7 ODBC driver needed

7. ResultSet with few rows invisible to ResultSet.next()

8. US-IL-DBA/DATA ARCHITECT

9. Private Resultset vs. Public Resultset

10. ResultSet.last() and ResultSet.absolute()

11. DatabaseMetaData.getTables() is incorrectly reporting System tables

12. Cant call DatabaseMetaData.getColumns() while in a transaction.