Re: Doubt more info - Mailing list pgsql-jdbc

From Barry Lind
Subject Re: Doubt more info
Date
Msg-id 3CF66987.5060008@xythos.com
Whole thread Raw
In response to Re: Doubt  ("Joe Shevland" <jshevland@j-elite.com>)
List pgsql-jdbc
Dave,

One typo in the code below:  'con.getMetaData()' should be
'con1.getMetaData()'.

The results I get when running against 7.2.1 with 7.2 driver is:

null null people id null null users people_id 0 3 3 people people_pkey 7
null null policy id null null users policy_id 1 3 3 policy policy_pkey 7

thanks,
--Barry


Dave Cramer wrote:
> 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
driverhave 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@yahoo.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@j-elite.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
>>
>>
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>



pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: Big problem inserting Russian characters into Postgres
Next
From: Noel Rappin
Date:
Subject: Re: Issues with Array Interface