Re: [Bug] ResultSet#getMetaData() returns null

From: Barry Lind <blind(at)xythos(dot)com>
To: Barry Lind <blind(at)xythos(dot)com>
Cc: Nic Ferrier <nferrier(at)tapsellferrier(dot)co(dot)uk>, Doug Kearns <djkea2(at)mugca(dot)its(dot)monash(dot)edu(dot)au>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: [Bug] ResultSet#getMetaData() returns null
Date: 2003-05-22 17:16:13
Message-ID: 3ECD05DD.3080309@xythos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Nic,

In looking at this some more, I don't think this will be as difficult as
I had feared. I discovered that ResultSetMetaData doesn't even use the
data that is passed to it, all it needs is the Field[] information. So
then it just boils down to the following question: Is the delayed
initialization of the RefCursorResultSet necessary? If so, I would like
to understand why it is necessary (some comments in the code would
probably be a good thing either way). This could be fixed in two ways:
1) by removing the delayed initialization altogether, or 2) by adding
the initialization check into the other methods (like getMetaData())
that can be called before next().

thanks,
--Barry

Barry Lind wrote:
> Nic,
>
> Could you look into this bug? (Let me know either way). The problem is
> specific to RefCursorResultSets. And since you submitted this code, it
> might be easier for you to think of a solution here, even if you don't
> code it. The problem is that the current logic in
> JdbcXRefCursorResultSet doesn't initialize the ResultSet until next() is
> called. However the logic in getMetaData() is assuming that the
> ResultSet is already initialized and passes the data and Field[] over. I
> am not really sure how this should work now that RefCursorResultSets are
> in the picture. Thus I would like your input.
>
> thanks,
> --Barry
>
> PS. This probably should be added as a test case as well.
>
>
> Doug Kearns wrote:
>
>> Hello all,
>>
>> ResultSet#getMetaData() is returning null, using the current CVS driver,
>> if called before ResultSet#next()
>>
>> <snippet>
>> db.setAutoCommit(false);
>>
>> CallableStatement st = db.prepareCall( "{ ? = call doit () }" );
>> st.registerOutParameter(1, Types.OTHER);
>>
>> st.execute();
>> ResultSet rs = (ResultSet) st.getObject(1);
>>
>> ResultSetMetaData md = rs.getMetaData();
>> System.out.println( "Column count = " + md.getColumnCount() );
>> //Exception in thread "main" java.lang.NullPointerException
>> //at
>> org.postgresql.jdbc2.AbstractJdbc2ResultSetMetaData.getColumnCount(AbstractJdbc2ResultSetMetaData.java:33)
>>
>> //at JDBCTest.main(JDBCTest.java:16)
>>
>> rs.next();
>> </snippet>
>>
>> Regards,
>> Doug
>>
>> ---------------------------(end of broadcast)---------------------------
>> TIP 4: Don't 'kill -9' the postmaster
>>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Fernando Nasser 2003-05-23 14:17:39 JDBC: Wrong type
Previous Message Fernando Nasser 2003-05-22 14:59:52 JDBC: Better initial capacity for StringBuffers reduces memory usage