6 public class JDBCStatement implements java.sql.Statement {
8 protected JDBCConnection conn;
9 protected JDBCResultSet rs;
11 protected int maxrows = 0;
13 public JDBCStatement(JDBCConnection conn) {
17 public void setFetchSize(int fetchSize) throws SQLException {
19 throw new SQLException("fetch size not 1");
23 public int getFetchSize() throws SQLException {
27 public int getMaxRows() throws SQLException {
31 public void setMaxRows(int max) throws SQLException {
33 throw new SQLException("max must be >= 0 (was " + max + ")");
38 public void setQueryTimeout(int seconds) throws SQLException {
39 conn.timeout = seconds * 1000;
40 if (conn.timeout < 0) {
41 conn.timeout = 120000;
42 } else if (conn.timeout < 1000) {
47 public int getQueryTimeout() throws SQLException {
48 return conn.timeout / 1000;
51 public ResultSet getResultSet() throws SQLException {
55 ResultSet executeQuery(String sql, String args[], boolean updonly)
57 SQLite.TableResult tr = null;
63 if (conn == null || conn.db == null) {
64 throw new SQLException("stale connection");
67 boolean starttrans = !conn.autocommit && !conn.intrans;
71 conn.db.exec("BEGIN TRANSACTION", null);
76 conn.db.exec(sql, null);
78 tr = conn.db.get_table(sql, maxrows);
82 conn.db.exec(sql, null, args);
84 tr = conn.db.get_table(sql, maxrows, args);
87 updcnt = (int) conn.db.changes();
88 } catch (SQLite.Exception e) {
90 conn.db.last_error() == SQLite.Constants.SQLITE_BUSY &&
91 conn.busy3(conn.db, ++busy)) {
93 if (starttrans && conn.intrans) {
94 conn.db.exec("ROLLBACK", null);
97 } catch (SQLite.Exception ee) {
100 int ms = 20 + busy * 10;
104 synchronized (this) {
107 } catch (java.lang.Exception eee) {
111 throw new SQLException(e.toString());
115 if (!updonly && tr == null) {
116 throw new SQLException("no result set produced");
118 if (!updonly && tr != null) {
119 rs = new JDBCResultSet(new TableResultX(tr), this);
124 public ResultSet executeQuery(String sql) throws SQLException {
125 return executeQuery(sql, null, false);
128 public boolean execute(String sql) throws SQLException {
129 return executeQuery(sql) != null;
132 public void cancel() throws SQLException {
133 if (conn == null || conn.db == null) {
134 throw new SQLException("stale connection");
139 public void clearWarnings() throws SQLException {
142 public Connection getConnection() throws SQLException {
146 public void addBatch(String sql) throws SQLException {
147 throw new SQLException("not supported");
150 public int[] executeBatch() throws SQLException {
151 throw new SQLException("not supported");
154 public void clearBatch() throws SQLException {
155 throw new SQLException("not supported");
158 public void close() throws SQLException {
162 public int executeUpdate(String sql) throws SQLException {
163 executeQuery(sql, null, true);
167 public int getMaxFieldSize() throws SQLException {
171 public boolean getMoreResults() throws SQLException {
179 public int getUpdateCount() throws SQLException {
183 public SQLWarning getWarnings() throws SQLException {
187 public void setCursorName(String name) throws SQLException {
188 throw new SQLException("not supported");
191 public void setEscapeProcessing(boolean enable) throws SQLException {
192 throw new SQLException("not supported");
195 public void setMaxFieldSize(int max) throws SQLException {
196 throw new SQLException("not supported");