Re: Java Studio Creator and postgresql jdbc - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: Java Studio Creator and postgresql jdbc
Date
Msg-id 410976C5.2050600@opencloud.com
Whole thread Raw
In response to Re: Java Studio Creator and postgresql jdbc  (Jeremiah Jahn <jeremiah@cs.earlham.edu>)
List pgsql-jdbc
Jeremiah Jahn wrote:
> bit of a repost here:
> I got the following from sun on this.
>
> Re: Supported DB Drivers
> Author: Valerie_Lipman
> Jul 25, 2004 2:02 PM
> (reply 4 of 4)
>
> We just tested postgresql in house and found that the driver is
> returning null for PreparedStatement.getMetaData()

The current driver returns null from getMetaData() if there is no active
resultset associated with the statement.

The javadoc says:

> Retrieves a ResultSetMetaData object that contains information about the
> columns of the ResultSet object that will be returned when this
> PreparedStatement object is executed.
>
> Because a PreparedStatement object is precompiled, it is possible to
> know about the ResultSet object that it will return without having to
> execute it. Consequently, it is possible to invoke the method
> getMetaData on a PreparedStatement object rather than waiting to execute
> it and then invoking the ResultSet.getMetaData method on the ResultSet
> object that is returned.

This is probably possible to implement when using a V3 connection
(server version >= 7.4) as we can send Parse/Bind/Describe/ClosePortal
to get a description of the portal without actually executing it. The
driver doesn't do this currently though.

I'd point out that it's probably the application at fault too. The
javadoc goes on to say:

> Returns:
>     the description of a ResultSet object's columns or null if the
> driver cannot return a ResultSetMetaData object

So 'null' is actually a legal return value (in fact, we'll probably have
to continue returning null when using a V2 connection).

-O

pgsql-jdbc by date:

Previous
From: Kris Jurka
Date:
Subject: Re: Bug in 7.4_213 driver: returns VARCHAR instead of
Next
From: Barry Lind
Date:
Subject: Re: Bug in 7.4_213 driver: returns VARCHAR instead of