Thread: BUG #1163: cursor "jdbc_curs_1" does not exist

BUG #1163: cursor "jdbc_curs_1" does not exist

From
"PostgreSQL Bugs List"
Date:
The following bug has been logged online:

Bug reference:      1163
Logged by:          Timo Nentwig

Email address:      tmp@nitwit.de

PostgreSQL version: 7.4

Operating system:   Linux

Description:        cursor "jdbc_curs_1" does not exist

Details:

Hi!

I read about 4000 html pages (i.e. Strings) from one table, compress them
with GZip and insert them as bytea into another table. Work fine for the
first 100 then this happens:

org.postgresql.util.PSQLException: ERROR: cursor "jdbc_curs_1" does not
exist

    at
org.postgresql.util.PSQLException.parseServerError(PSQLException.java:139)
    at org.postgresql.core.QueryExecutor.executeV3(QueryExecutor.java:152)
    at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:100)
    at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:67)
org.postgresql.jdbc1.AbstractJdbc1ResultSet.next(AbstractJdbc1ResultSet.jav
    at a:157)
    at f4t.obsolete.migration.CompressHtml.compress(CompressHtml.java:40)
    at f4t.obsolete.migration.CompressHtml.main(CompressHtml.java:70)



My JDBC driver is 74.213. This is my convertion code:

    PreparedStatement insertHtml = f4t.prepareStatement("INSERT INTO
legacy.zhtml (id, zhtml) VALUES (?, ?)");
        PreparedStatement selectHtml = f4t.prepareStatement("SELECT urlid, html
FROM html");

        f4t.setAutoCommit(false);

        selectHtml.setFetchSize(100);

        ResultSet row = selectHtml.executeQuery();

        for (int j = 1; row.next(); j++)
        {
            String id = row.getString("urlid");
            String html = row.getString("html");

            ByteArrayOutputStream bos =  new ByteArrayOutputStream();
            DataOutputStream dos =  new DataOutputStream(bos);
            WritableUtils.writeCompressedString(dos, html);

            insertHtml.setString(1, id);
            insertHtml.setBytes(2, bos.toByteArray());
            insertHtml.execute();

            System.out.print('.');

            if(j%100==0)
            {
                System.out.println();
                f4t.commit();
            }
        }

        f4t.commit();
        f4t.setAutoCommit(true);