473,321 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,321 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 8587
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.