Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Get "user" tables

Reply
Thread Tools

Get "user" tables

 
 
WP
Guest
Posts: n/a
 
      04-29-2008
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
 
Reply With Quote
 
 
 
 
WP
Guest
Posts: n/a
 
      04-29-2008
On 29 Apr, 17:18, WP <mindcoo...@gmail.com> 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.
 
Reply With Quote
 
 
 
 
Ronny Schuetz
Guest
Posts: n/a
 
      04-29-2008
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/...eMetaData.html

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

Ronny

 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      04-29-2008
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/...eMetaData.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
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      05-03-2008
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get ubuntu ! Get ubuntu ! Get ubuntu ! Get ubuntu ! Getubuntu Windows 64bit 1 06-01-2009 08:54 AM
How to get database metadata information (i.e. existing tables and columns in tables) Chris Brat Python 5 08-22-2006 05:25 PM
Tables within tables Otuatail HTML 7 08-02-2004 04:42 AM
using a datagrid to update two sql tables...I can't get it work TN Bella ASP .Net 1 06-15-2004 02:16 AM
Text after 2 tables actually appears between 2 tables ! Peter Bassett HTML 3 08-15-2003 06:46 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57