~ubuntu-branches/ubuntu/maverick/libpgjava/maverick

« back to all changes in this revision

Viewing changes to src/interfaces/jdbc/org/postgresql/jdbc1/Jdbc1RefCursorResultSet.java

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Vandyck
  • Date: 2006-04-25 00:07:07 UTC
  • mfrom: (1.3.1 upstream) (3.1.1 dapper)
  • Revision ID: james.westby@ubuntu.com-20060425000707-6lr2s0awuz4z48hm
* Drop support for the old jdbc2 driver (can be reverted if wanted)
  (closes: #358345).
* New upstream (thanks to Wolfgang Baer).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.postgresql.jdbc1;
2
 
 
3
 
import java.sql.SQLException;
4
 
import org.postgresql.core.QueryExecutor;
5
 
import org.postgresql.core.BaseStatement;
6
 
import org.postgresql.PGRefCursorResultSet;
7
 
 
8
 
/** A real result set based on a ref cursor.
9
 
 *
10
 
 * @author Nic Ferrier <nferrier@tapsellferrier.co.uk>
11
 
 */
12
 
public class Jdbc1RefCursorResultSet extends Jdbc1ResultSet
13
 
        implements PGRefCursorResultSet
14
 
{
15
 
 
16
 
        // The name of the cursor being used.
17
 
        String refCursorHandle;
18
 
 
19
 
        // Indicates when the result set has activaly bound to the cursor.
20
 
        boolean isInitialized = false;
21
 
 
22
 
        
23
 
        Jdbc1RefCursorResultSet(BaseStatement statement, String refCursorName)
24
 
        {
25
 
                super(statement, null, null, null, -1, 0L);
26
 
                this.refCursorHandle = refCursorName;
27
 
        }
28
 
 
29
 
        public String getRefCursor ()
30
 
        {
31
 
                return refCursorHandle;
32
 
        }
33
 
 
34
 
        public boolean next () throws SQLException
35
 
        {
36
 
                if (isInitialized)
37
 
                        return super.next();
38
 
                // Initialize this res set with the rows from the cursor.
39
 
                String[] toExec = { "FETCH ALL IN \"" + refCursorHandle + "\";" };
40
 
                QueryExecutor.execute(toExec, new String[0], this);
41
 
                isInitialized = true;
42
 
                return super.next();
43
 
        }
44
 
}