473,503 Members | 1,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getPrimaryKey on Db2

TP
Hi all,

I am new to Db2 but not to databases.

Here is a snippet of my code
=============
Connection conn = getConnection();
Statement stmt;
stmt = conn.createStatement();
DatabaseMetaData dbmd = conn.getMetaData();
ResultSet rs = dbmd.getPrimaryKeys(null, null, tableName);
cat.debug("b4 rs next"+ rs);
cat.debug("rs next" +rs.next());
cat.debug("pk = + "+ rs.getString("PK_NAME"));
while (rs.next()) {
cat.debug("inside rs next");
String name = rs.getString("TABLE_NAME");
String columnName = rs.getString("COLUMN_NAME");
String keySeq = rs.getString("KEY_SEQ");
String pkName = rs.getString("PK_NAME");
cat.debug("table name : " + name);
cat.debug("column name: " + columnName);
cat.debug("sequence in key: " + keySeq);
cat.debug("primary key name: " + pkName);
cat.debug("");
}
=============================
Here the tableNAme is DSN811A.EMP. So it is the standard employess
table and there is a primary key in there called EMPNO.

rs.next() returns false. and i get an exception at trying to get
rs.getString("PK_NAME"). If I remove that line then the rs.next loop
does not get entered.

According to the documentation I should get the PK_NAME returned and
the rest of the information.

Please help me out here.

Thanks for your help.

TP.
Nov 12 '05 #1
0 1198

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1607
by: Mike Cannon | last post by:
I'm having a problem with the newer version of win32all and Python 2.3 with code that works fine on Python-2.2 (details below). Both machines are Windows XP. The code that breaks is derived...
37
3209
by: Tim Marshall | last post by:
From http://www.mvps.org/access/tencommandments.htm 9th item: Thou shalt not use "SendKeys", "Smart Codes" or "GoTo" (unless the GoTo be part of an OnError process) for these will lead you...
8
36063
by: hoofbeats95 | last post by:
I don't think this should be this complicated, but I can't figure it out. I've worked with C# for several years now, but in a web environment, not with windows form. I have a form with a query...
41
3152
by: sukatoa | last post by:
This is for my friend. He is a HRM student and was assigned to demo on how to operate a Simple Hotel front-desk system. I've searched on the net to help him, but all of those freeware softwares...
1
13284
by: HarishAdea | last post by:
Hi, I am trying to run the JAVA pgm, but it is giving error as "selection does not contain a main type". The filename is "ScoreLeadSummary.java" when i try to run it or debug,it gives the pop...
3
3053
oll3i
by: oll3i | last post by:
when i run my create.jsp that populates the database i get javax.ejb.EJBException error it throws the exception at line phoneHome.create("01", "01", "0957205114"); i have three lookups...
0
7089
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
7339
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...
0
7463
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...
0
5581
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,...
1
5017
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
4678
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...
0
3157
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1515
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
738
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.