473,725 Members | 2,276 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

View Tables of DB2 Database using JDBC

1 New Member
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.SQLTABLE S;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:8 3)
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:7 384)
at com.ibm.db2.jcc .c.t.a(t.java:5 974)
at com.ibm.db2.jcc .c.t.getTables( t.java:5885)
...
Sep 7 '07 #1
2 8625
SueDaws
1 New Member
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.SQLTABLE S;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:8 3)
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:7 384)
at com.ibm.db2.jcc .c.t.a(t.java:5 974)
at com.ibm.db2.jcc .c.t.getTables( t.java:5885)
...
Mar 17 '08 #2
docdiesel
297 Recognized Expert Contributor
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
6268
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 pointing to "loginValidate.jsp" * a loginValidate.jsp page that references logic to validate requests * a loginBean class used to pass info between the JSP and validation logic * a usersDAO class used to perform lookups in a USERS
0
1240
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 failover. There is a 'push' subscription from A to B and C. MSSQL 2K SP3. Win2K. This has been working perfectly for several months. Recently I tried to add a column to one of the tables using
4
2716
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 add insert and delete triggers to each of the underlying tables. The triggers modify a different set of tables in the same database as the view (different than the underlying table). The problem is those triggers aren't fired when inserting or...
3
5183
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 f1\r\nfor read only\r\n I get: SQL0104N An unexpected token \"create view
1
2840
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? Database: Access 97 Connection: ADO 2.0 Please reply to my email aswell as the group if possible.
9
3557
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 'Syntax error in CREATE TABLE statement' even though I am not creating a table, but a Database // - - - - - - - - - - - - sun.jdbc.odbc.JdbcOdbc aSQL=CREATE DATABASE dbtest; java.sql.SQLException:
5
2454
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 already been covered please point me to some URL, or the list archives, or what you think is fine. My issue is that I need to do some replication from Oracle tables to PSQL. One-way only, incremental, and to a remote machine.
2
6671
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 connect fine using db2connect and run queries etc. The problem is when I try to use my java application to connect using the same DSN. The way the db has been configured is that I am
2
9840
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 to open in datasheet view. As an experiment, I deleted all rows in all tables; after that, the query took only seconds to open in both design view and datasheet view. From these facts, I conclude that Access is evaluating the query when I go to...
0
8889
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9116
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8099
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6011
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.