pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ingo Luetkebohle <ingo@blank.pages.de>
To: pgsql-interfaces@postgresql.org
Subject: jdbc: getBinaryStream blocks on second call
Date: Sun, 3 Dec 2000 17:13:02 +0100
Message-ID: <20001203171302.B1619@blank.pages.de> (raw)

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[])

-- 
	Ingo Luetkebohle / ingo@blank.pages.de / 95428014
/
|PraxisXML Open Source contact; Computational Linguistics
|student; Fargonauten.DE sysadmin; Gimp Registry (not-)maintainer;



view thread (7+ messages)  latest in thread

Message-ID: <20001203171302.B1619@blank.pages.de>
Permalink:  ../20001203171302.B1619@blank.pages.de/
Also on:    postgresql.org/message-id/20001203171302.B1619@blank.pages.de

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: ingo@blank.pages.de
  Subject: Re: jdbc: getBinaryStream blocks on second call
  In-Reply-To: <20001203171302.B1619@blank.pages.de>

* 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