I am not sure if you are looking for a pure java approach but I believe you can issue a Select statement straight against  SYSIBM.SQLSCHEMAS, SYSIBM.SQLTABLES, and SYSIBM.SQLCOLUMNS to get a list of schemas, tables, and fields/attributes.

Regards, 
Ken




________________________________
From: "Holm, Paul" <pholm@xxxxxxxxxxxxxxxxx>
To: Java 400 List <java400-l@xxxxxxxxxxxx>
Sent: Friday, August 30, 2013 1:18 PM
Subject: Re: JAVA400-L Digest, Vol 11, Issue 70


Jim,

We make extensive use of both SQL ResultSet metadata and Database Metadata.
You can fairly easily get what you need from these 2 APIs.

This may help, it sounds similar to what you are trying to do:
http://search400.techtarget.com/tip/Building-dynamic-JDBC-components-and-utilities


HTH,

Paul Holm


On Fri, Aug 30, 2013 at 10:00 AM, <java400-l-request@xxxxxxxxxxxx> wrote:

Send JAVA400-L mailing list submissions to
        java400-l@xxxxxxxxxxxx

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.midrange.com/mailman/listinfo/java400-l
or, via email, send a message with subject or body 'help' to
        java400-l-request@xxxxxxxxxxxx

You can reach the person managing the list at
        java400-l-owner@xxxxxxxxxxxx

When replying, please edit your Subject line so it is more specific
than "Re: Contents of JAVA400-L digest..."


Today's Topics:

    1. List of schemas and tables via JDBC? (James H. H. Lampert)
    2. RE: List of schemas and tables via JDBC? (Dan Kimmel)
    3. Re: List of schemas and tables via JDBC? (Brian Johnson)
    4. Re: List of schemas and tables via JDBC? (James H. H. Lampert)
    5. Re: List of schemas and tables via JDBC? (Sam_L)


----------------------------------------------------------------------

message: 1
date: Thu, 29 Aug 2013 17:34:35 -0700
from: "James H. H. Lampert" <jamesl@xxxxxxxxxxxxxxxxx>
subject: List of schemas and tables via JDBC?

I haven't even started looking, but would anybody happen to know where I
need to look, for how one gets a list of databases/schemas/tables
available at any given JDBC URL?

And are the relevant methods already exposed in JDBCR4?

(I'm beginning to think that by the time I'm done with extensions to
JDBCR4, it will be more like JDBCR4000.)

--
JHHL


------------------------------

message: 2
date: Fri, 30 Aug 2013 14:46:38 +0000
from: Dan Kimmel <dkimmel@xxxxxxxxxxxxxxx>
subject: RE: List of schemas and tables via JDBC?

There's a pretty good explanation here
https://www.simple-talk.com/sql/t-sql-programming/exploring-your-database-schema-with-sql/though it focuses on SQL Server.

E F Codd's fifth rule (rule no. 4) says that to be a relational database a
system must have a catalog of its parts that can be queried using the same
language used for querying ordinary tables. This "schema" was standardized
in SQL-98, I think, with a standard meta-schema name "INFORMATION_SCHEMA"
and tables within that schema "TABLES", "TABLE-CONSTRAINTS", "VIEWS",
"TRIGGERS", and so on. See here for a good list
http://dev.mysql.com/doc/refman/5.0/en/information-schema.html. Before
that all the databases supported the systables, sysviews, sysconstraints,
etc. de facto naming convention.

So, the JDBC standard doesn't need to provide any methods for querying for
a list of schemas as SQL itself already has defined them.

-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-
bounces@xxxxxxxxxxxx] On Behalf Of James H. H. Lampert
Sent: Thursday, August 29, 2013 7:35 PM
To: 'Java Programming on and around the IBM i'
Subject: List of schemas and tables via JDBC?

I haven't even started looking, but would anybody happen to know where I
need to look, for how one gets a list of databases/schemas/tables
available at any given JDBC URL?

And are the relevant methods already exposed in JDBCR4?

(I'm beginning to think that by the time I'm done with extensions to
JDBCR4, it will be more like JDBCR4000.)

--
JHHL
--
This is the Java Programming on and around the IBM i (JAVA400-L) mailing
list
To post a message email: JAVA400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.





------------------------------

message: 3
date: Fri, 30 Aug 2013 10:04:37 -0500
from: Brian Johnson <brian.johnson.mn@xxxxxxxxx>
subject: Re: List of schemas and tables via JDBC?

And here's i-specific info (presumably also available in newer
infocenters):


http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/db2/rbafzmstcatalog.htm

On Fri, Aug 30, 2013 at 9:46 AM, Dan Kimmel <dkimmel@xxxxxxxxxxxxxxx>
wrote:
There's a pretty good explanation here
https://www.simple-talk.com/sql/t-sql-programming/exploring-your-database-schema-with-sql/though it focuses on SQL Server.
...
-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-
bounces@xxxxxxxxxxxx] On Behalf Of James H. H. Lampert
Sent: Thursday, August 29, 2013 7:35 PM
To: 'Java Programming on and around the IBM i'
Subject: List of schemas and tables via JDBC?

I haven't even started looking, but would anybody happen to know where I
need to look, for how one gets a list of databases/schemas/tables
available at any given JDBC URL?


Brian Johnson
brian.johnson.mn@xxxxxxxxx


------------------------------

message: 4
date: Fri, 30 Aug 2013 08:37:28 -0700
from: "James H. H. Lampert" <jamesl@xxxxxxxxxxxxxxxxx>
subject: Re: List of schemas and tables via JDBC?

On 8/30/13 7:46 AM, Dan Kimmel wrote:
. . .
E F Codd's fifth rule (rule no. 4) says that to be a relational
database a system must have a catalog of its parts that can be
queried using the same language used for querying ordinary tables.
. . .
So, the JDBC standard doesn't need to provide any methods for
querying for a list of schemas as SQL itself already has defined
them.

Fascinating!

Or to quote an old exchange between Groucho and Margaret Dumont,
"I'm fascinated!"
"I'm fascinated too. Right here on the arm."

--
JHHL


------------------------------

message: 5
date: Fri, 30 Aug 2013 12:03:57 -0400
from: Sam_L <lennon_s_j@xxxxxxxxxxx>
subject: Re: List of schemas and tables via JDBC?

JDBC API Tutorial and Reference, Third Edition, by Fisher, Ellis and
Bruce has a chapter on Database Metadata.  (If I ever get time I plan to
read more of this book and do some experimentation with Java.)

I'm not an expert, but they have some Java sample code (con is a
Connection object):

DatabaseMetaData dbmd = con.getMetaData(0;
ResultSet rs = dbmd.getSchemas();
while (rs.next());
        String s = rs.getString(1);
        System.out.println("Schema name = " + s);
}

It looks like there is a boatload of information in the metadata object.

I picked up a copy of the book a couple of years ago used (read cheap)
on e-bay.  You might find it useful.

Sam


On 8/29/2013 8:34 PM, James H. H. Lampert wrote:
I haven't even started looking, but would anybody happen to know where I
need to look, for how one gets a list of databases/schemas/tables
available at any given JDBC URL?

And are the relevant methods already exposed in JDBCR4?

(I'm beginning to think that by the time I'm done with extensions to
JDBCR4, it will be more like JDBCR4000.)

--
JHHL


------------------------------

--
This is the Java Programming on and around the IBM i (JAVA400-L) digest
list
To post a message email: JAVA400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.



End of JAVA400-L Digest, Vol 11, Issue 70
*****************************************





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2022 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.