Get "user" tables

Discussion in 'Java' started by WP, Apr 29, 2008.

  1. WP

    WP Guest

    Hello, I need to communicate with a db2 database from a java program
    and this java program needs to check which "user tables" there are. I
    came up with the following query which I tried in Control Center:
    select tabname, tabschema from syscat.tables where tabschema !=
    'SYSCAT' and tabschema != 'SYSIBM' and tabschema != 'SYSIBMADM' and
    tabschema != 'SYSSTAT' and tabschema != 'SYSTOOLS';
    It seems to work, it returns just the tables that I have created
    myself. But it is this the best way? The java program doesn't specify
    a user upon connection because it's connecting through a local system
    account I think. Therefore it cannot perform selection based on
    username.

    I just wanted to hear if I should proceed with this solution or if
    there's some better approach.

    - WP
    WP, Apr 29, 2008
    #1
    1. Advertising

  2. WP

    WP Guest

    On 29 Apr, 17:18, WP <> wrote:
    > Hello, I need to communicate with a db2 database from a java program
    > and this java program needs to check which "user tables" there are. I
    > came up with the following query which I tried in Control Center:
    > select tabname, tabschema from syscat.tables where tabschema !=
    > 'SYSCAT' and tabschema != 'SYSIBM' and tabschema != 'SYSIBMADM' and
    > tabschema != 'SYSSTAT' and tabschema != 'SYSTOOLS';
    > It seems to work, it returns just the tables that I have created
    > myself. But it is this the best way? The java program doesn't specify
    > a user upon connection because it's connecting through a local system
    > account I think. Therefore it cannot perform selection based on
    > username.
    >
    > I just wanted to hear if I should proceed with this solution or if
    > there's some better approach.
    >
    > - WP


    I am so sorry, I sent this to the wrong newsgroup. It was meant for
    the db2 group.
    WP, Apr 29, 2008
    #2
    1. Advertising

  3. Hi,

    > Hello, I need to communicate with a db2 database from a java program
    > and this java program needs to check which "user tables" there are. I
    > [...]
    > myself. But it is this the best way? The java program doesn't specify
    > a user upon connection because it's connecting through a local system
    > account I think. Therefore it cannot perform selection based on
    > username.


    You could check out the Database Metadata:

    http://java.sun.com/j2se/1.4.2/docs/api/java/sql/DatabaseMetaData.html

    retrievable via Connection#getMetaData(). Works fine for Oracle, no idea
    about DB2.

    Ronny
    Ronny Schuetz, Apr 29, 2008
    #3
  4. WP

    Arne Vajhøj Guest

    Ronny Schuetz wrote:
    >> Hello, I need to communicate with a db2 database from a java program
    >> and this java program needs to check which "user tables" there are. I
    >> [...]
    >> myself. But it is this the best way? The java program doesn't specify
    >> a user upon connection because it's connecting through a local system
    >> account I think. Therefore it cannot perform selection based on
    >> username.

    >
    > You could check out the Database Metadata:
    >
    > http://java.sun.com/j2se/1.4.2/docs/api/java/sql/DatabaseMetaData.html
    >
    > retrievable via Connection#getMetaData(). Works fine for Oracle, no idea
    > about DB2.


    It is defined in the JDBC API - DB2 will support it.

    Arne
    Arne Vajhøj, Apr 30, 2008
    #4
  5. WP

    Arne Vajhøj Guest

    WP wrote:
    > Hello, I need to communicate with a db2 database from a java program
    > and this java program needs to check which "user tables" there are. I
    > came up with the following query which I tried in Control Center:
    > select tabname, tabschema from syscat.tables where tabschema !=
    > 'SYSCAT' and tabschema != 'SYSIBM' and tabschema != 'SYSIBMADM' and
    > tabschema != 'SYSSTAT' and tabschema != 'SYSTOOLS';
    > It seems to work, it returns just the tables that I have created
    > myself. But it is this the best way? The java program doesn't specify
    > a user upon connection because it's connecting through a local system
    > account I think. Therefore it cannot perform selection based on
    > username.
    >
    > I just wanted to hear if I should proceed with this solution or if
    > there's some better approach.


    Either the above or the JDBC way (described in a previous post).

    DB2 does not support the standard INFORMATION_SCHEMA views.

    Arne
    Arne Vajhøj, May 3, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Benign Vanilla

    Nested Tables and User Controls

    Benign Vanilla, Jun 24, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    364
    Mark Sandfox
    Jun 24, 2004
  2. Isofarro
    Replies:
    0
    Views:
    798
    Isofarro
    Jul 1, 2003
  3. Peter Bassett
    Replies:
    3
    Views:
    925
    Augustus
    Aug 15, 2003
  4. Otuatail

    Tables within tables

    Otuatail, Jul 31, 2004, in forum: HTML
    Replies:
    7
    Views:
    494
  5. Chris Brat
    Replies:
    5
    Views:
    695
    =?iso-8859-1?q?Luis_M._Gonz=E1lez?=
    Aug 22, 2006
Loading...

Share This Page