X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0ADD0329F61 for ; Mon, 18 Oct 2004 15:50:14 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 00894-04 for ; Mon, 18 Oct 2004 14:50:05 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 0258E329F45 for ; Mon, 18 Oct 2004 15:50:05 +0100 (BST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i9IEo0J7001858 for ; Mon, 18 Oct 2004 14:50:00 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i9IEd8F3097861 for pgsql-jdbc@postgresql.org; Mon, 18 Oct 2004 14:39:08 GMT From: tomas.johansson@agent25.se (Tomas) X-Newsgroups: comp.databases.postgresql.interfaces.jdbc Subject: NullPointerException in ResultSetMetaData getColumnCount when using on a resultset from a stored function Date: 18 Oct 2004 07:39:12 -0700 Organization: http://groups.google.com Lines: 48 Message-ID: <2e107e13.0410180639.70aea0e0@posting.google.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: groups-abuse@google.com To: pgsql-jdbc@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/191 X-Sequence-Number: 11296 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'