Re: How to find primary key?

From: Gert Rijs <g.rijs_at_genimen.com>
Date: Sun, 19 Mar 2000 16:00:04 +0100
Message-ID: <8b2pul$sp2$1_at_porthos.nl.uu.net>


Take a look at the DatabaseMetaData class (obtainable with getDatabaseMetaData() on your Connection instance). It has all the methods you need (primary keys, foreign keys (called 'imported' and 'exported' keys in DatabaseMetaData).

hth,
gert

--
==========================================================================
I used to think that the brain was the most wonderful organ in my body.
Then I realized who was telling me this.
==========================================================================
G.C. Rijs Genimen BV
g.rijs_at_genimen.com   www.genimen.com
==========================================================================

Randall J. Parr <RParr_at_TemporalArts.COM> wrote in message
news:38D4E50B.1D5A641_at_TemporalArts.COM...

> I am trying to impliment a load using JDBC wherein I read the table
> name, some column names, and associated column data from a file
> (delimited or XML). The primary key columns are in the column names /
> data BUT I don't know which columns they are (based on the file I'm
> reading). Even if this information was in the file, I would need to
> verify the table I'm targeting does in fact have that primary key. I can
> insert the records fine BUT to use the records to update I need to
> determine from the database which are the primary key columns (by name).
>
> Essentially I'm trying to do the following:
>
> {
> insert record into table
>
> if fails because of duplicate primary key
> {
> determine the primary key of the current table
>
> retrieve the already existing record
>
> modify the retrieved record using my load data
>
> update the already existing record in the database
>
> }
>
> }
>
> My primary concern, now, is Oracle although I'm hoping to impliment this
> in as portable a fashion as possible.
>
> Thanks.
> R.Parr
> TemporalArts
> 608.833.4578
>
>
Received on Sun Mar 19 2000 - 16:00:04 CET

Original text of this message