Thread: ResultSet got NullPointerException on getMetaData calls

ResultSet got NullPointerException on getMetaData calls

From
"Gaetano Sferra"
Date:
Hello to all,
I got a NullPointerException when try to call getMetaData method on a refcursor
mapped on a ResultSet.
This is an example scenario:

create table mytable(name varchar, surname varchar, email varchar);
create or replace function myfunction() returns refcursor as'
declare
rc refcursor;
begin
open rc for select * from mytable order by surname;
return rc;
end;

This is a piece of code using the above stored function:

conn.setAutoCommit(false);
CallableStatement proc = conn.prepareCall("{ ? = call myfunction() }");
proc.registerOutParameter(1, Types.OTHER);
proc.execute();
ResultSet rs = (ResultSet) proc.getObject(1);
ResultSetMetaData rsmd = rs.getMetaData(); // <- NullPointerException

I'm using the PostgreSQL 7.4 server and the PostgreSQL JDBC 7.4 drivers.
Reading a previous post by Tomas on this ML I've tried to use the PostgreSQL
JDBC 8.0 driver without succes, the exception stills here.

Thank you for support,
Gaetano Sferra





____________________________________________________________
Libero ADSL: 3 mesi gratis e navighi a 1.2 Mega, senza costi di attivazione.
Abbonati subito su http://www.libero.it



Re: ResultSet got NullPointerException on getMetaData calls

From
"Gaetano Sferra"
Date:
Hello,
I'm sorry for my previous post, the NullPointerException is on
getColumnCount() call!

> conn.setAutoCommit(false);
> CallableStatement proc = conn.prepareCall("{ ? = call myfunction() }");
> proc.registerOutParameter(1, Types.OTHER);
> proc.execute();
> ResultSet rs = (ResultSet) proc.getObject(1);
> ResultSetMetaData rsmd = rs.getMetaData(); // <- NullPointerException **WRONG**
   int cols = rsdm.getColumnCount(); // <- NullPointerException **THE TRUE ONE**

I'm sorry for mistakes and thank you for support again,
Gaetano Sferra




____________________________________________________________
Libero ADSL: 3 mesi gratis e navighi a 1.2 Mega, senza costi di attivazione.
Abbonati subito su http://www.libero.it



Re: ResultSet got NullPointerException on getMetaData calls

From
Kris Jurka
Date:

On Mon, 6 Dec 2004, Gaetano Sferra wrote:

> I got a NullPointerException when try to call getMetaData method on a
> refcursor mapped on a ResultSet.

ResultSets based on refcursors currently don't have any metadata
associated with them.  The whole refcursor implementation could be
upgraded to really use the V3 protocol (which would also allow it to
respect setFetchSize), but no one has tackled this project, so you are
unfortunately out of luck at the moment.

Kris Jurka


Re: ResultSet got NullPointerException on getMetaData calls

From
Kris Jurka
Date:

On Mon, 6 Dec 2004, Kris Jurka wrote:

> ResultSets based on refcursors currently don't have any metadata
> associated with them.  The whole refcursor implementation could be
> upgraded to really use the V3 protocol (which would also allow it to
> respect setFetchSize), but no one has tackled this project, so you are
> unfortunately out of luck at the moment.
>

Actually, rechecking this report.  Things seem to work fine in the 8.0
driver and ResultSetMetaData is available for refcursor ResultSets.  The
fetchsize is still an open item though.

Kris Jurka