From: | tomas(dot)johansson(at)agent25(dot)se (Tomas) |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | NullPointerException in ResultSetMetaData getColumnCount when using on a resultset from a stored function |
Date: | 2004-10-18 14:39:12 |
Message-ID: | 2e107e13.0410180639.70aea0e0@posting.google.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
How can you get metadata from a resultset that is returned from a
stored function ?
I have tried the code below with the latest "pg74.215.jdbc3.jar" at
http://jdbc.postgresql.org/download.html
but the invocation of metaData.getColumnCount()) below will lead to a
NullPointerException:
java.lang.NullPointerException
at org.postgresql.jdbc2.AbstractJdbc2ResultSetMetaData.getColumnCount(AbstractJdbc2ResultSetMetaData.java:34)
private void testCallable(Connection conn) throws Exception
{
CallableStatement call = conn.prepareCall("{ ? = call
myfunction() }");
call.registerOutParameter(1, Types.OTHER);
call.execute();
ResultSet results = (ResultSet) call.getObject(1);
ResultSetMetaData metaData = results.getMetaData();
System.out.println("getColumnCount: " +
metaData.getColumnCount());
results.close();
call.close();
}
CREATE TABLE public.mytable
(
mycolumn int4,
mycolumn2 int4
)
CREATE OR REPLACE FUNCTION public.myfunction()
RETURNS refcursor AS
'
DECLARE
ref refcursor;
BEGIN
OPEN ref FOR
SELECT mycolumn, mycolumn2 FROM mytable;
RETURN ref;
END;
'
LANGUAGE 'plpgsql'
From | Date | Subject | |
---|---|---|---|
Next Message | Tony Grant | 2004-10-18 17:10:57 | boolean problem |
Previous Message | Jair da Silva Ferreira Jr | 2004-10-18 12:57:00 | Re: problem with dates when using a java calendar object with |