pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
DatabaseMetaData
11+ messages / 7 participants
[nested] [flat]

* DatabaseMetaData
@ 2001-08-10 15:07 Liam Stewart <liams@redhat.com>
  2001-08-10 23:13 ` Re: DatabaseMetaData Rene Pijlman <rpijlman@wanadoo.nl>
  0 siblings, 1 reply; 11+ messages in thread

From: Liam Stewart @ 2001-08-10 15:07 UTC (permalink / raw)
  To: pgsql-jdbc


I've taken a look at the results of the dbMeta tests in the JDBC test
suite. I know that Peter has taken a look at these so I've just got some
additional notes w.r.t. to failures.

In dbMeta1, the test for supportsStoredProcedures fails consistently.
The method returns false, but the test harness is expecting true and
considers false to be an invalid response. The reason for this is that
the JDBC test suite is doing tests for J2EE compliance of the JDBC
driver being tested, and one of the conditions is that
supportsStoredProcedures should always return true. For regular JDBC
compliance, returning false is alright. So, ignore those tests (unless
we want the JDBC driver to be J2EE compliant).

In the PostgreSQL driver, there are some methods that throw
SQLExceptions because they are not implemented yet (isCatalogAtStart,
getCatalogSeparator, getUDTs). But other unimplemented methods, such as
getTablePrivileges, getVersionColumns, getExportedKeys, and
getCrossReference return null. Until they are implemented, they should
throw an SQLException.

null != empty ResultSet, so getTypeInfo should not have a fallback
return value of null, but rather should throw an SQLException when the
metadata is not available. In general, I think that better checking for
unavailable metadata can be done.

The SQLExceptions thrown by unimplemented methods will be caught by the
JDBC test harness and the tests will be flagged as errors due to the
fact, again, that the test suite is testing for J2EE compliance: all
methods should be implemented and none should throw exceptions. For more
information on the JDBC and J2EE, see the J2EE Api, section 6.2.2.3.

Liam

-- 
Liam Stewart :: Red Hat Canada, Ltd. :: liams@redhat.com



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: DatabaseMetaData
  2001-08-10 15:07 DatabaseMetaData Liam Stewart <liams@redhat.com>
@ 2001-08-10 23:13 ` Rene Pijlman <rpijlman@wanadoo.nl>
  2001-08-13 16:07   ` Re: DatabaseMetaData Liam Stewart <liams@redhat.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Rene Pijlman @ 2001-08-10 23:13 UTC (permalink / raw)
  To: Liam Stewart <liams@redhat.com>; +Cc: pgsql-jdbc

On Fri, 10 Aug 2001 11:07:45 -0400, you wrote:
>In dbMeta1, the test for supportsStoredProcedures fails consistently.
>The method returns false, but the test harness is expecting true and
>considers false to be an invalid response. The reason for this is that
>the JDBC test suite is doing tests for J2EE compliance of the JDBC
>driver being tested, and one of the conditions is that
>supportsStoredProcedures should always return true. For regular JDBC
>compliance, returning false is alright. 

I'm not sure if this is true. The JDBC book
(http://java.sun.com/docs/books/jdbc/) says in the description
of supportsStoredProcedures: "checks whether this database
supports stored procedure calls using the stored procedure
escape syntax". And in section A.1.3: "... must be supported by
a JDBC Compliant driver... Where appropriate, an escape syntax
must be included for stored procedures, ...". I see no mention
of J2EE with respect to this requirement.

>In the PostgreSQL driver, there are some methods that throw
>SQLExceptions because they are not implemented yet (isCatalogAtStart,
>getCatalogSeparator, getUDTs). But other unimplemented methods, such as
>getTablePrivileges, getVersionColumns, getExportedKeys, and
>getCrossReference return null. Until they are implemented, they should
>throw an SQLException.

So noted on http://lab.applinet.nl/postgresql-jdbc/ under
"miscellaneous".

As an aside, I've just updated this page with an explanation of
the Blob/Clob/Lob issues and the proposal from Barry Lind, as
well as some other issues that have been posted on this list.

>null != empty ResultSet, so getTypeInfo should not have a fallback
>return value of null, but rather should throw an SQLException when the
>metadata is not available.

So noted under "DatabaseMetaData".

>In general, I think that better checking for
>unavailable metadata can be done.

I'm not sure what you mean by that. But maybe I'm the problem,
its getting late :-)

>The SQLExceptions thrown by unimplemented methods will be caught by the
>JDBC test harness and the tests will be flagged as errors due to the
>fact, again, that the test suite is testing for J2EE compliance: all
>methods should be implemented and none should throw exceptions. 

They're allowed to throw exceptions by the signature, but they'd
better not when the test is running :-)

>For more information on the JDBC and J2EE, see the J2EE Api, 
>section 6.2.2.3.

Hmmm... what book are you refering to? I have the "Java 2 EE
Platform and Components Specifications", but it doesn't have a
section 6.2.2.3.

Regards,
René Pijlman



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: DatabaseMetaData
  2001-08-10 15:07 DatabaseMetaData Liam Stewart <liams@redhat.com>
  2001-08-10 23:13 ` Re: DatabaseMetaData Rene Pijlman <rpijlman@wanadoo.nl>
@ 2001-08-13 16:07   ` Liam Stewart <liams@redhat.com>
  2001-08-13 20:28     ` Re: DatabaseMetaData Rene Pijlman <rpijlman@wanadoo.nl>
  0 siblings, 1 reply; 11+ messages in thread

From: Liam Stewart @ 2001-08-13 16:07 UTC (permalink / raw)
  To: pgsql-jdbc

On Sat, Aug 11, 2001 at 01:13:34AM +0200, Rene Pijlman wrote:
> I'm not sure if this is true. The JDBC book
> (http://java.sun.com/docs/books/jdbc/) says in the description
> of supportsStoredProcedures: "checks whether this database
> supports stored procedure calls using the stored procedure
> escape syntax". And in section A.1.3: "... must be supported by
> a JDBC Compliant driver... Where appropriate, an escape syntax
> must be included for stored procedures, ...". I see no mention
> of J2EE with respect to this requirement.

Ok, I see what you're looking at. However, the book states the escapes
should only be supported when the underlying DBMS supports them and that
escape syntaxes must be included for stored procedures etc where
appropriate. Does PostgreSQL support stored procedures using a stored
procedures escape syntax? If yes, we should return yes, if no, we should
return no until that functionality is added. Both cases are allowed,
AFAICS. The book doesn't mention that drivers should always return true
for this procedure.

> >In general, I think that better checking for
> >unavailable metadata can be done.
> 
> I'm not sure what you mean by that. But maybe I'm the problem,
> its getting late :-)

Actually, I'm not sure what I was saying anymore .. :P never mind this
statement until I figure it out myself :)

> Hmmm... what book are you refering to? I have the "Java 2 EE
> Platform and Components Specifications", but it doesn't have a
> section 6.2.2.3.

"Java 2 EE Specification, v1.2"

Liam

-- 
Liam Stewart :: Red Hat Canada, Ltd. :: liams@redhat.com



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: DatabaseMetaData
  2001-08-10 15:07 DatabaseMetaData Liam Stewart <liams@redhat.com>
  2001-08-10 23:13 ` Re: DatabaseMetaData Rene Pijlman <rpijlman@wanadoo.nl>
  2001-08-13 16:07   ` Re: DatabaseMetaData Liam Stewart <liams@redhat.com>
@ 2001-08-13 20:28     ` Rene Pijlman <rpijlman@wanadoo.nl>
  0 siblings, 0 replies; 11+ messages in thread

From: Rene Pijlman @ 2001-08-13 20:28 UTC (permalink / raw)
  To: Liam Stewart <liams@redhat.com>; +Cc: pgsql-jdbc

On Mon, 13 Aug 2001 12:07:59 -0400, you wrote:
>Ok, I see what you're looking at. However, the book states the escapes
>should only be supported when the underlying DBMS supports them and that
>escape syntaxes must be included for stored procedures etc where
>appropriate. Does PostgreSQL support stored procedures using a stored
>procedures escape syntax? If yes, we should return yes, if no, we should
>return no until that functionality is added. Both cases are allowed,
>AFAICS. The book doesn't mention that drivers should always return true
>for this procedure.

You're right.

>"Java 2 EE Specification, v1.2"

Ah, I see, this is one of the subbooks in my book. Well, I think
we'll have to check for J2EE conformance as well, since I guess
the driver will be used on J2EE platforms more and more.

Regards,
René Pijlman



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* DatabaseMetadata
@ 2002-02-17 18:15 Tiago Antao <tra_ejb@yahoo.com>
  2002-02-17 20:36 ` Re: DatabaseMetadata Justin Clift <justin@postgresql.org>
  0 siblings, 1 reply; 11+ messages in thread

From: Tiago Antao @ 2002-02-17 18:15 UTC (permalink / raw)
  To: pgsql-jdbc

Hi!

I am doing a project that involves the use of the DatabaseMetadata,
namely I need Foreign keys...
A few things that I have found:
1. PgSQL does not have FK meta-data available for foreign keys as they
are implemented with triggers
2. Accordingly the driver cannot supply meta-data (check eg,
DatabaseMetadata.getImportedKeys), which is correct, but...
3. getImportedKeys always returns a null, which very easely breaks any
JDBC code, as is very far way from what is expected
4. I think the best solution would be to return an empty ResultSet, or
at least raise a SQL Exception (I would favour the first).
5. I could volunteer to try to implement better return for these type of
functions (it seems to be easy), if you agree with my solution just say
and I will try to implement it.

I am stuck with Oracle because of this...

Best regards,
Tiago
PS - I have 7.1.3 source







_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com




^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: DatabaseMetadata
  2002-02-17 18:15 DatabaseMetadata Tiago Antao <tra_ejb@yahoo.com>
@ 2002-02-17 20:36 ` Justin Clift <justin@postgresql.org>
  0 siblings, 0 replies; 11+ messages in thread

From: Justin Clift @ 2002-02-17 20:36 UTC (permalink / raw)
  To: Tiago Antao <tra_ejb@yahoo.com>; +Cc: pgsql-jdbc

Hi Tiago,

You should try the PostreSQL 7.2 JDBC driver, as it has support for
DatabaseMetadata and is backwards compatible with PG 7.1.3.

http://jdbc.postgresql.org

:-)

Regards and best wishes,

Justin Clift


Tiago Antao wrote:
> 
> Hi!
> 
> I am doing a project that involves the use of the DatabaseMetadata,
> namely I need Foreign keys...
> A few things that I have found:
> 1. PgSQL does not have FK meta-data available for foreign keys as they
> are implemented with triggers
> 2. Accordingly the driver cannot supply meta-data (check eg,
> DatabaseMetadata.getImportedKeys), which is correct, but...
> 3. getImportedKeys always returns a null, which very easely breaks any
> JDBC code, as is very far way from what is expected
> 4. I think the best solution would be to return an empty ResultSet, or
> at least raise a SQL Exception (I would favour the first).
> 5. I could volunteer to try to implement better return for these type of
> functions (it seems to be easy), if you agree with my solution just say
> and I will try to implement it.
> 
> I am stuck with Oracle because of this...
> 
> Best regards,
> Tiago
> PS - I have 7.1.3 source
> 
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

-- 
"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
   - Indira Gandhi



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* DatabaseMetaData
@ 2006-05-22 22:34 Glenn Holmer <gholmer@weycogroup.com>
  2006-05-22 23:17 ` Re: DatabaseMetaData Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Glenn Holmer @ 2006-05-22 22:34 UTC (permalink / raw)
  To: pgsql-jdbc

Can someone give me the right incantation to get the names of the 
columns in a table using DatabaseMetaData?  I'm trying

dmd = conn.getMetaData();
rs = dmd.getColumns("pg_attribute", "public", "tsoldto", null);
while (rs.next()) {

(where "tsoldto" is the name of my table) and not getting anything in 
the result set.  What is that last argument supposed to be if I want to 
retrieve all the column names, and are the first two correct?

-- 
____________________________________________________________
Glenn Holmer                          gholmer@weycogroup.com
Software Engineer                        phone: 414-908-1809
Weyco Group, Inc.                          fax: 414-908-1601



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: DatabaseMetaData
  2006-05-22 22:34 DatabaseMetaData Glenn Holmer <gholmer@weycogroup.com>
@ 2006-05-22 23:17 ` Kris Jurka <books@ejurka.com>
  2006-05-23 13:25   ` Re: DatabaseMetaData Glenn Holmer <gholmer@weycogroup.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Kris Jurka @ 2006-05-22 23:17 UTC (permalink / raw)
  To: Glenn Holmer <gholmer@weycogroup.com>; +Cc: pgsql-jdbc



On Mon, 22 May 2006, Glenn Holmer wrote:

> Can someone give me the right incantation to get the names of the
> columns in a table using DatabaseMetaData?  I'm trying
>
> dmd = conn.getMetaData();
> rs = dmd.getColumns("pg_attribute", "public", "tsoldto", null);
>
> (where "tsoldto" is the name of my table) and not getting anything in
> the result set.  What is that last argument supposed to be if I want to
> retrieve all the column names, and are the first two correct?
>

The first argument should be your database name, but this is not actually 
causing a problem because that parameter is ignored because pg does not 
support cross database calls.  Other than that it looks good.  Are you 
sure it's in the public schema?  Are you sure it wasn't created with a 
case sensitive table name "tSoldTo" or something?

Kris Jurka



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: DatabaseMetaData
  2006-05-22 22:34 DatabaseMetaData Glenn Holmer <gholmer@weycogroup.com>
  2006-05-22 23:17 ` Re: DatabaseMetaData Kris Jurka <books@ejurka.com>
@ 2006-05-23 13:25   ` Glenn Holmer <gholmer@weycogroup.com>
  2006-05-23 13:50     ` Re: DatabaseMetaData Oliver Jowett <oliver@opencloud.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Glenn Holmer @ 2006-05-23 13:25 UTC (permalink / raw)
  To: pgsql-jdbc

On Monday 22 May 2006 18:17, you wrote:
> The first argument should be your database name, but this is not
> actually causing a problem because that parameter is ignored because
> pg does not support cross database calls.  Other than that it looks
> good.  Are you sure it's in the public schema?  Are you sure it
> wasn't created with a case sensitive table name "tSoldTo" or
> something?

Thanks.  The DDL to create the table was:

CREATE TABLE tsoldto(
  uid_pk      INTEGER
...

and I found that while this works:

dmd = conn.getMetaData();
rs = dmd.getColumns("licensee", "public", "tsoldto", "%");
// rs = dmd.getColumns("licensee", "public", "tSoldTo", "%");
while (rs.next()) {
  columnNames.add(rs.getString("COLUMN_NAME"));
}
rs.close();

using the commented-out line does not.  I thought table names were 
case-insensitive? (this is with Postgres 8.0.3 and build 316 of the 
JDBC driver).

-- 
____________________________________________________________
Glenn Holmer                          gholmer@weycogroup.com
Software Engineer                        phone: 414-908-1809
Weyco Group, Inc.                          fax: 414-908-1601



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: DatabaseMetaData
  2006-05-22 22:34 DatabaseMetaData Glenn Holmer <gholmer@weycogroup.com>
  2006-05-22 23:17 ` Re: DatabaseMetaData Kris Jurka <books@ejurka.com>
  2006-05-23 13:25   ` Re: DatabaseMetaData Glenn Holmer <gholmer@weycogroup.com>
@ 2006-05-23 13:50     ` Oliver Jowett <oliver@opencloud.com>
  2006-05-23 18:28       ` Re: DatabaseMetaData Glenn Holmer <gholmer@weycogroup.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Oliver Jowett @ 2006-05-23 13:50 UTC (permalink / raw)
  To: Glenn Holmer <gholmer@weycogroup.com>; +Cc: pgsql-jdbc

Glenn Holmer wrote:

> I thought table names were 
> case-insensitive?

They are case sensitive, but forced to lowercase when used unquoted in a 
query. See DatabaseMetaData.supportsMixedCaseQuotedIdentifiers() etc.

-O



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: DatabaseMetaData
  2006-05-22 22:34 DatabaseMetaData Glenn Holmer <gholmer@weycogroup.com>
  2006-05-22 23:17 ` Re: DatabaseMetaData Kris Jurka <books@ejurka.com>
  2006-05-23 13:25   ` Re: DatabaseMetaData Glenn Holmer <gholmer@weycogroup.com>
  2006-05-23 13:50     ` Re: DatabaseMetaData Oliver Jowett <oliver@opencloud.com>
@ 2006-05-23 18:28       ` Glenn Holmer <gholmer@weycogroup.com>
  0 siblings, 0 replies; 11+ messages in thread

From: Glenn Holmer @ 2006-05-23 18:28 UTC (permalink / raw)
  To: ; +Cc: pgsql-jdbc

On Tuesday 23 May 2006 08:50, Oliver Jowett wrote:
> Glenn Holmer wrote:
> > I thought table names were
> > case-insensitive?
>
> They are case sensitive, but forced to lowercase when used unquoted
> in a query. See DatabaseMetaData.supportsMixedCaseQuotedIdentifiers()
> etc.

Thanks all, working great now.

-- 
____________________________________________________________
Glenn Holmer                          gholmer@weycogroup.com
Software Engineer                        phone: 414-908-1809
Weyco Group, Inc.                          fax: 414-908-1601



^ permalink  raw  reply  [nested|flat] 11+ messages in thread


end of thread, other threads:[~2006-05-23 18:28 UTC | newest]

Thread overview: 11+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-08-10 15:07 DatabaseMetaData Liam Stewart <liams@redhat.com>
2001-08-10 23:13 ` Rene Pijlman <rpijlman@wanadoo.nl>
2001-08-13 16:07   ` Liam Stewart <liams@redhat.com>
2001-08-13 20:28     ` Rene Pijlman <rpijlman@wanadoo.nl>
2002-02-17 18:15 DatabaseMetadata Tiago Antao <tra_ejb@yahoo.com>
2002-02-17 20:36 ` Re: DatabaseMetadata Justin Clift <justin@postgresql.org>
2006-05-22 22:34 DatabaseMetaData Glenn Holmer <gholmer@weycogroup.com>
2006-05-22 23:17 ` Kris Jurka <books@ejurka.com>
2006-05-23 13:25   ` Glenn Holmer <gholmer@weycogroup.com>
2006-05-23 13:50     ` Oliver Jowett <oliver@opencloud.com>
2006-05-23 18:28       ` Glenn Holmer <gholmer@weycogroup.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox