pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nedim Cholich <nedim@cholich.com>
To: Kris Jurka <books@ejurka.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Jdbc4ResultSet getClob and getBlob are calling getLong internally
Date: Mon, 1 Feb 2010 15:39:15 -0500
Message-ID: <2f8a6c901002011239r40e7cdd4k66321122e12829a6@mail.gmail.com> (raw)
In-Reply-To: <alpine.BSO.2.00.1002011512140.30625@leary.csoft.net>
References: <2f8a6c901002011053w4ec6425bodb502c67d4e2b2dc@mail.gmail.com>
	<alpine.BSO.2.00.1002011512140.30625@leary.csoft.net>

On Mon, Feb 1, 2010 at 15:15, Kris Jurka <books@ejurka.com> wrote:
> On Mon, 1 Feb 2010, Nedim Cholich wrote:
>> After getting 'org.postgresql.util.PSQLException: Bad value for type
>> long' I found these two methods in Jdbc4ResultSet:
>>
>>   public java.sql.Clob getClob(int i) throws SQLException
>>   {
>>       return new Jdbc4Clob(connection, getLong(i));
>>   }
>>
>> Calling getLong here has to be wrong?
>>
>
> No.  Large Objects are not stored directly inline, but as a pointer to other
> storage.  The getLong is retrieving the external storage which Jdbc4Clob
> will then stream from the server on demand.  You are probably trying to call
> getClob on a text or varchar column and that's not going to work.  It might
> be nice to provide that interface, but there's no benefit (other than
> compatibility) to the user.  If you have text data stored inline, then it's
> already been transferred over to the client side in the ResultSet, so
> there's no point in using a streaming interface.

Yes, it's a TEXT column and yes I'm calling rs.getClob(columnName);

What am I suppose to call instead?

The above call produces:
... blah ...
Caused by: org.postgresql.util.PSQLException: Bad value for type long
: url=http://<removed;
	at org.postgresql.jdbc2.AbstractJdbc2ResultSet.toLong(AbstractJdbc2ResultSet.java:2796)
	at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getLong(AbstractJdbc2ResultSet.java:2019)
	at org.postgresql.jdbc4.Jdbc4ResultSet.getClob(Jdbc4ResultSet.java:43)
	at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getClob(AbstractJdbc2ResultSet.java:384)

getFixedString(columnIndex) method called from
AbstractJdbc2ResultSet:2019 is returning an actual column value
(String) which toLong is trying to convert to long and failing.

Thanks!

What am I missing?



view thread (6+ messages)  latest in thread

Message-ID: <2f8a6c901002011239r40e7cdd4k66321122e12829a6@mail.gmail.com>
Permalink:  ../2f8a6c901002011239r40e7cdd4k66321122e12829a6@mail.gmail.com/
Also on:    postgresql.org/message-id/2f8a6c901002011239r40e7cdd4k66321122e12829a6@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: nedim@cholich.com, books@ejurka.com
  Subject: Re: Jdbc4ResultSet getClob and getBlob are calling getLong internally
  In-Reply-To: <2f8a6c901002011239r40e7cdd4k66321122e12829a6@mail.gmail.com>
  References: <2f8a6c901002011053w4ec6425bodb502c67d4e2b2dc@mail.gmail.com> <alpine.BSO.2.00.1002011512140.30625@leary.csoft.net> <2f8a6c901002011239r40e7cdd4k66321122e12829a6@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox