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.
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.