01: /*
02: * Created on 26/11/2003
03: *
04: * To change the template for this generated file go to
05: * Window - Preferences - Java - Code Generation - Code and Comments
06: */
07: package org.mandarax.jdbc.client;
08:
09: import java.sql.*;
10: import org.mandarax.jdbc.rpc.*;
11:
12: /**
13: * Utility to issue query and to fetch the results in chunks.
14: * @author <A HREF="mailto:mandarax@jbdietrich.com">Jens Dietrich</A>
15: * @version 3.3.2 <29 December 2004>
16: * @since 3.0
17: */
18: public class QueryHelper {
19: /**
20: * Execute a query using the call and a particular transport.
21: * @param transport the transport (plumbing)
22: * @param call the call that describes which method to call on the server in order to obtain
23: * the result set
24: * @param fetchSize the fetch size used (number of rows fetched at once)
25: * @param the caller (statement, connection etc)
26: * @return a result set
27: */
28: public static ResultSet executeQuery(Transport transport,
29: Call call, int fetchSize, Object caller)
30: throws SQLException {
31: // create server object
32: String rsId = (String) transport.perform(call);
33:
34: // get meta data
35: call = new Call(rsId, "ResultSet_getMetaData");
36: ResultSetMetaData metaData = (ResultSetMetaData) transport
37: .perform(call);
38:
39: // build result set
40: Statement stmnt = null;
41: if (caller instanceof Statement)
42: stmnt = (Statement) caller;
43: ResultSetImpl rs = new ResultSetImpl(metaData, stmnt, transport);
44: rs.setId(rsId);
45: rs.setFetchSize(fetchSize);
46:
47: return rs;
48: }
49: }
|