From: Greg Speegle <Greg@10happythings.com>
To: Ingo Luetkebohle <ingo@blank.pages.de>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: jdbc: getBinaryStream blocks on second call
Date: Sun, 03 Dec 2000 13:10:21 -0600
Message-ID: <3A2A9A9D.9000803@10happythings.com> (raw)
References: <20001203171302.B1619@blank.pages.de>
Within JDBC 1.0, it is required to access the columns in a result set
row from left to right
and only once. Since the Postgres JDBC driver is not totally 2.0, it's
not mandatory, but it
is a real good idea. I'd suggest storing the byte array somewhere so you
don't have to
read it twice. If you have to read it twice, the only way to gaurantee
that it works, is to
close the Statement and do it again.
Greg Speegle
Baylor University
Ingo Luetkebohle wrote:
> Hello,
>
> I'm using the Postgresql-JDBC interface inside of a Jave Server Page
> and request a large object. When the page is first called, it works
> fine. When its called twice for the same database row, the
> ResultSet.getBinaryStream method blocks infinetely. This is on
> postgresql 7.0.3 (from RPM, on Linux, glibc).
>
> The code is something like:
>
> dbc.setAutoCommit(false);
> Statement st = dbc.createStatement();
> ResultSet rs = st.executeQuery("SELECT contents FROM file WHERE id=" + id);
> dbc.commit();
> if(rs.next()) {
> Reader r = new InputStreamReader(rs.getBinaryStream(1));
> char buf[] = new char[2048];
> for(int read = r.read(buf); read != -1; read = r.read(buf))
> out.write(buf, 0, read);
>
> out.flush();
> r.close();
> is.close();
> }
>
> (yes, I known that the getBytes method is more convenient but the
> JspWriter class a JSP page provides can't write byte[], only char[])
>
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 using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: Greg@10happythings.com, ingo@blank.pages.de
Subject: Re: jdbc: getBinaryStream blocks on second call
In-Reply-To: <3A2A9A9D.9000803@10happythings.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