I would like to get the names of the primary key columns of a table.   

I tried to use the map package clases to figure out the name of the primary 
key like so

...
                MyTableMapBuilder mapBuilder = new MyTableMapBuilder();
                mapBuilder.doBuild();
                DatabaseMap map = mapBuilder.getDatabaseMap();
                ColumnMap[] colMap = map.getIdTable().getColumns();
                
                String keyColumnName=null;
                for (int i=0;i<colMap.length;i++) {
                        if (colMap[i].isPrimaryKey()) {
                                keyColumnName=colMap[i].getColumnName();
                                break;
                        }
                }
                
                System.out.println("key column name: " + keyColumnName);
...

but this returns 'ID_TABLE_ID' and the name of my primary key column is simply 
'ID'.

Is there another way? 

Justin


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to