Re: Doubt more info

From: Dave Cramer <Dave(at)micro-automation(dot)net>
To: Dave Cramer <Dave(at)micro-automation(dot)net>
Cc: Joe Shevland <jshevland(at)j-elite(dot)com>, priya k <k_priya17(at)yahoo(dot)com>, "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Doubt more info
Date: 2002-05-30 14:59:24
Message-ID: 1022770764.1427.76.camel@inspiron.cramers
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

The following works on the current CVS code. Can someone verify that it
works on the latest release.

public void testForeignKeys()
{
try
{
Connection con1 = JDBC2Tests.openDB();
JDBC2Tests.createTable( con1, "people", "id int4 primary key, name
text" );
JDBC2Tests.createTable( con1, "policy", "id int4 primary key, name
text" );
JDBC2Tests.createTable( con1, "users", "id int4 primary key,
people_id int4, policy_id int4,"+
"CONSTRAINT people FOREIGN KEY
(people_id) references people(id),"+
"constraint policy FOREIGN KEY
(policy_id) references policy(id)" );

DatabaseMetaData dbmd = con.getMetaData();
assertNotNull(dbmd);

ResultSet rs = dbmd.getImportedKeys(null, "", "users" );

while ( rs.next() )
{
for ( int i=0; i < 14 ; i++ )
{
System.out.print( rs.getString(i+1) + ' ' );
}
System.out.println();
}
JDBC2Tests.dropTable( con1, "users" );
JDBC2Tests.dropTable( con1, "people" );
JDBC2Tests.dropTable( con1, "policy" );

}
catch (SQLException ex)
{
fail(ex.getMessage());
}
}

Dave

On Thu, 2002-05-30 at 08:53, Dave Cramer wrote:
> Actually, this is the second time I have heard this, so I am leaning
> towards this being a bug.
>
> Dave
> On Thu, 2002-05-30 at 06:20, Joe Shevland wrote:
> > Hi Priya,
> >
> > Unsure, as I don't tend to use the metadata methods a lot, but it may be the case that the latest CVS sources of the driver have solved the problem. I've CC'ed the main list as I'm fairly sure this has come up before and is working.
> >
> > Cheers,
> > Joe
> >
> > -----Original Message-----
> > From: priya k [mailto:k_priya17(at)yahoo(dot)com]
> > Sent: Thursday, 30 May 2002 19:57
> > To: Joe Shevland
> > Subject: RE: Doubt
> >
> > Thank you for the immediate reply.
> > I downloaded & tried retrieving primary key, foreign key(namely getExported, getImportedKey). Both of them are working, but getImportedKey is able to retrieve only one foreign key , eventhough the table has 2. Sir, what to do ?
> > Waiting for ur reply,
> > With regards,
> > Priya.
> >
> >
> > Joe Shevland <jshevland(at)j-elite(dot)com> wrote:
> > Hi there,
> >
> > These metadata methods will work with the latest versions of the PostgreSQL JDBC driver.
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 5: Have you checked our extensive FAQ?
> >
> > http://www.postgresql.org/users-lounge/docs/faq.html
> >
> >
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>
>

In response to

  • Re: Doubt at 2002-05-30 12:53:23 from Dave Cramer

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Noel Rappin 2002-05-30 15:10:30 Issues with Array interface?
Previous Message Dave Cramer 2002-05-30 12:53:23 Re: Doubt