473,420 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,420 software developers and data experts.

View Tables of DB2 Database using JDBC

Can someone help me please with the following code:
Expand|Select|Wrap|Line Numbers
  1. try {
  2.             DatabaseMetaData metadata=con.getMetaData();
  3.             System.out.println(metadata.getDriverName());
  4.             System.out.println("Driver version: " +metadata.getDriverVersion());
  5.  
  6.             System.out.print("JDBC version: " + metadata.getJDBCMajorVersion());
  7.             System.out.println("." +metadata.getJDBCMinorVersion());
  8.  
  9.             System.out.println("Database product name: " +metadata.getDatabaseProductName());
  10.             System.out.println("Database product version: " +metadata.getDatabaseProductVersion());
  11.             System.out.print("Database version: " +metadata.getDatabaseMajorVersion());
  12.             System.out.println("." +metadata.getDatabaseMinorVersion());
  13.  
  14.             String[] names = {"TABLE"};
  15.             //exception occurs on next line:
  16.             ResultSet tables = metadata.getTables(null,"%", null, names);
  17.             while (tables.next()) {
  18.                 String tableName = tables.getString("TABLE_NAME");
  19.                 System.out.println(tableName);
  20.             }
  21.         } catch (SQLException se) {
  22.             System.out.println("Error: could not get tables");
  23.             se.printStackTrace();
  24.             System.exit(1);
  25.         }
  26.  
I get the following error, which I have not been able to resolve:

IBM DB2 JDBC Universal Driver Architecture
Driver version: 3.1.57
JDBC version: 3.0
Database product name: DB2/AIX64
Database product version: SQL09013
Database version: 9.1
Error: could not get tables
com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -443, SQLSTATE: 38553, SQLERRMC: SYSIBM.SQLTABLES;TABLES;SYSIBM:CLI:-805
at com.ibm.db2.jcc.c.fg.d(fg.java:1340)
at com.ibm.db2.jcc.b.gb.k(gb.java:351)
at com.ibm.db2.jcc.b.gb.e(gb.java:96)
at com.ibm.db2.jcc.b.w.e(w.java:83)
at com.ibm.db2.jcc.b.vb.i(vb.java:164)
at com.ibm.db2.jcc.c.fg.q(fg.java:1311)
at com.ibm.db2.jcc.c.gg.d(gg.java:2386)
at com.ibm.db2.jcc.c.hg.V(hg.java:146)
at com.ibm.db2.jcc.c.t.a(t.java:7384)
at com.ibm.db2.jcc.c.t.a(t.java:5974)
at com.ibm.db2.jcc.c.t.getTables(t.java:5885)
...
Sep 7 '07 #1
2 8603
Did you ever get a reply to this post? I ask because we are also getting the same error - DB2 version 8 fixpack 14, AIX 5.3 ML4 and ML5 - and have been unable to resolve it.

Can someone help me please with the following code:
Expand|Select|Wrap|Line Numbers
  1. try {
  2.             DatabaseMetaData metadata=con.getMetaData();
  3.             System.out.println(metadata.getDriverName());
  4.             System.out.println("Driver version: " +metadata.getDriverVersion());
  5.  
  6.             System.out.print("JDBC version: " + metadata.getJDBCMajorVersion());
  7.             System.out.println("." +metadata.getJDBCMinorVersion());
  8.  
  9.             System.out.println("Database product name: " +metadata.getDatabaseProductName());
  10.             System.out.println("Database product version: " +metadata.getDatabaseProductVersion());
  11.             System.out.print("Database version: " +metadata.getDatabaseMajorVersion());
  12.             System.out.println("." +metadata.getDatabaseMinorVersion());
  13.  
  14.             String[] names = {"TABLE"};
  15.             //exception occurs on next line:
  16.             ResultSet tables = metadata.getTables(null,"%", null, names);
  17.             while (tables.next()) {
  18.                 String tableName = tables.getString("TABLE_NAME");
  19.                 System.out.println(tableName);
  20.             }
  21.         } catch (SQLException se) {
  22.             System.out.println("Error: could not get tables");
  23.             se.printStackTrace();
  24.             System.exit(1);
  25.         }
  26.  
I get the following error, which I have not been able to resolve:

IBM DB2 JDBC Universal Driver Architecture
Driver version: 3.1.57
JDBC version: 3.0
Database product name: DB2/AIX64
Database product version: SQL09013
Database version: 9.1
Error: could not get tables
com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -443, SQLSTATE: 38553, SQLERRMC: SYSIBM.SQLTABLES;TABLES;SYSIBM:CLI:-805
at com.ibm.db2.jcc.c.fg.d(fg.java:1340)
at com.ibm.db2.jcc.b.gb.k(gb.java:351)
at com.ibm.db2.jcc.b.gb.e(gb.java:96)
at com.ibm.db2.jcc.b.w.e(w.java:83)
at com.ibm.db2.jcc.b.vb.i(vb.java:164)
at com.ibm.db2.jcc.c.fg.q(fg.java:1311)
at com.ibm.db2.jcc.c.gg.d(gg.java:2386)
at com.ibm.db2.jcc.c.hg.V(hg.java:146)
at com.ibm.db2.jcc.c.t.a(t.java:7384)
at com.ibm.db2.jcc.c.t.a(t.java:5974)
at com.ibm.db2.jcc.c.t.getTables(t.java:5885)
...
Mar 17 '08 #2
docdiesel
297 Expert 100+
Hi,

I'm not a java programmer, but I may offer a workaround from DB2 side. To get a list of all non-system tables you may query the following sql statement:
Expand|Select|Wrap|Line Numbers
  1. select
  2.   creator,name
  3. from
  4.   sysibm.systables
  5. where creator not like 'SYS%' ;
This gives you the schema and the tablename. If you'd like to get the system tables as well, then just forget about the WHERE clause.

Regards,

Bernd
Mar 17 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: mdh | last post by:
I am trying to learn the basics of MVC applications using a Tomcat infrastructure. I'm starting by building a simple application with: * a login.jsp page for a basic login form with a action...
0
by: Patrick Johnson | last post by:
Hello, I'm not sure where to start with this. I have 3 MSSQL servers. Server A publishes a database to B and C. The publication is set up as transactional, immediate updating with queued...
4
by: stacdab | last post by:
We have a partitioned view with 4 underlying tables. The view and each of the underlying tables are in seperate databases on the same server. Inserts and deletes on the view work fine. We then...
3
by: Mike Schuler | last post by:
Hello, I thought I knew sql, but when I send this as an argument of a Statement.execute(): create view mike.unnamed1(WORKDEPT) as select f1.WORKDEPT as \"WORKDEPT\"\r\nfrom MIKE.EMPLOYEE...
1
by: Chad Reid | last post by:
I was wondering what the VBA code would be to test to see if a view already exists, or how to overwrite a view if it already exists. Also, how would I do the same for a regular table? ...
9
by: Albretch | last post by:
.. I am trying to create a database in a MS Access DB via JDBC drivers. I have tried both sun.jdbc.odbc.JdbcOdbcDriver and ids.sql.IDSDriver From some reason both drivers Exceptions tell me...
5
by: Miguel Guzman Miranda | last post by:
Hi there, First of all, I suppose my problem should be at least farly common, but haven't had luck trying to find what I need by searching on the docs, google, etc. So please if this issue has...
2
by: anokun7 | last post by:
Hi, I am connecting to a DB2 v7.1 server from windows using JDBC type 2 (I figured out that type 4 is only for 8 and upwards). I used DB2 Connect to create a system DSN and seem to be able to...
2
by: existential.philosophy | last post by:
This is a new problem for me: I have some queries that open very slowly in design view. My benchmark query takes about 20 minutes to open in design view. That same query takes about 20 minutes...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.