
> > > > To work
> > > > around this you can use explicit cursors (see the DECLARE CURSOR,
> > > > FETCH, and MOVE sql commands for postgres).

I'm unable to get this to work using the default distribution JDBC driver. 
(7.2). Here's a code snippet

      conn.setAutoCommit(false) ;
      stmt.execute("BEGIN") ;
      stmt.execute("DECLARE mysursor CURSOR FOR SELECT icol FROM mtable") ;
      ResultSet rs = null ;
      if (stmt.execute("FETCH 10000 IN mycursor"))
	rs = stmt.getResultSet() ;

The FETCH statement returns an update count of 1, but no ResultSet.
If I try executeQuery, a "no rows found" exception is thrown.

Equivalent code in the C library interface works just fine.

I need a workaround, because default ResultSet processing in the JDBC
driver (and also the jxDBCon driver) pretty much blow out the memory 
of the JVM. 

Wed, 16 Oct 2002 07:55:07 -0400
Dave Tenny <tenny@attbi.com>
Re: [JDBC] Out of memory error on huge resultset
This code work for me :
	Connection db = DriverManager.getConnection(url,user,passwd);
	PreparedStatement st = db.prepareStatement("begin;declare c1 cursor for 
select * from a");
	st.execute();
	st = db.prepareStatement("fetch 100 in c1");
	ResultSet rs = st.executeQuery();
	//rs.setFetchSize(100);
	while (rs.next() ) {
		s = rs.getString(1);
		System.out.println(s);
	}
	st = db.prepareStatement("commit");
	st.execute();
	st.close();
	db.close();

regards
Haris Peco
On Wednesday 16 October 2002 01:55 pm, Dave Tenny wrote:
> > > > > To work
> > > > > around this you can use explicit cursors (see the DECLARE CURSOR,
> > > > > FETCH, and MOVE sql commands for postgres).
>
> I'm unable to get this to work using the default distribution JDBC driver.
> (7.2). Here's a code snippet
>
>       conn.setAutoCommit(false) ;
>       stmt.execute("BEGIN") ;
>       stmt.execute("DECLARE mysursor CURSOR FOR SELECT icol FROM mtable") ;
>       ResultSet rs = null ;
>       if (stmt.execute("FETCH 10000 IN mycursor"))
> 	rs = stmt.getResultSet() ;
>
> The FETCH statement returns an update count of 1, but no ResultSet.
> If I try executeQuery, a "no rows found" exception is thrown.
>
> Equivalent code in the C library interface works just fine.
>
> I need a workaround, because default ResultSet processing in the JDBC
> driver (and also the jxDBCon driver) pretty much blow out the memory
> of the JVM.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly


Wed, 16 Oct 2002 14:40:07 +0200
snpe <snpe@snpe.co.yu>
Re: [JDBC] Out of memory error on huge resultset