117c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpepackage SQLite.JDBC2z;
2417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
3417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughesimport java.sql.*;
4417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughesimport java.util.*;
5417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
6417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughespublic class JDBCStatement implements java.sql.Statement {
7417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
8417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    protected JDBCConnection conn;
9417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    protected JDBCResultSet rs;
10417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    protected int updcnt;
117a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes    protected int maxrows = 0;
12417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    private ArrayList<String> batch;
13417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
14417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public JDBCStatement(JDBCConnection conn) {
157a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	this.conn = conn;
167a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	this.updcnt = 0;
177a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	this.rs = null;
1817c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe	this.batch = null;
19417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
20417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
21417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public void setFetchSize(int fetchSize) throws SQLException {
2217c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe	if (fetchSize != 1) {
2317c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe	    throw new SQLException("fetch size not 1");
2417c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe	}
25417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
26417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
27417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public int getFetchSize() throws SQLException {
287a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	return 1;
29417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
30417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
31417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public int getMaxRows() throws SQLException {
327a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	return maxrows;
33417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
34417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
35417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public void setMaxRows(int max) throws SQLException {
364538aff6d563d32cd1c5d2f7b349809384a0a540Jeremy Sharpe	if (max < 0) {
374538aff6d563d32cd1c5d2f7b349809384a0a540Jeremy Sharpe	    throw new SQLException("max must be >= 0 (was " + max + ")");
384538aff6d563d32cd1c5d2f7b349809384a0a540Jeremy Sharpe	}
397a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	maxrows = max;
40417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
41417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
42417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public void setFetchDirection(int fetchDirection) throws SQLException {
437a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	throw new SQLException("not supported");
44417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
45417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
46417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public int getFetchDirection() throws SQLException {
477a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	return ResultSet.FETCH_UNKNOWN;
48417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
49417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
50417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public int getResultSetConcurrency() throws SQLException {
517a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	return ResultSet.CONCUR_READ_ONLY;
52417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
53417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
54417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public int getResultSetType() throws SQLException {
557a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	return ResultSet.TYPE_SCROLL_INSENSITIVE;
56417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
57417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
58417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public void setQueryTimeout(int seconds) throws SQLException {
591eb14211d55adc833f0826ae7e96ff5478e7e3e6Jeremy Sharpe	// BEGIN android-changed: more closely follow specification:
601eb14211d55adc833f0826ae7e96ff5478e7e3e6Jeremy Sharpe	// "[throws SQLException if] this method is called on a closed Statement or the condition
611eb14211d55adc833f0826ae7e96ff5478e7e3e6Jeremy Sharpe	// seconds >= 0 is not satisfied"
621eb14211d55adc833f0826ae7e96ff5478e7e3e6Jeremy Sharpe	// (http://java.sun.com/javase/6/docs/api/java/sql/Statement.html#setQueryTimeout(int))
631eb14211d55adc833f0826ae7e96ff5478e7e3e6Jeremy Sharpe	if (isClosed()) {
641eb14211d55adc833f0826ae7e96ff5478e7e3e6Jeremy Sharpe	    throw new SQLException("can't set a query timeout on a closed statement");
651eb14211d55adc833f0826ae7e96ff5478e7e3e6Jeremy Sharpe	} else if (seconds < 0) {
661eb14211d55adc833f0826ae7e96ff5478e7e3e6Jeremy Sharpe	    throw new SQLException("can't set a query timeout of less than 0 seconds");
671eb14211d55adc833f0826ae7e96ff5478e7e3e6Jeremy Sharpe	} else if (seconds == 0) {
681eb14211d55adc833f0826ae7e96ff5478e7e3e6Jeremy Sharpe	    // An argument of 0 seconds should set an unlimited timeout. However, since this was not
691eb14211d55adc833f0826ae7e96ff5478e7e3e6Jeremy Sharpe	    // done previously, I assume it isn't implemented and use the same implementation.
707a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	    conn.timeout = 5000;
711eb14211d55adc833f0826ae7e96ff5478e7e3e6Jeremy Sharpe	} else {
721eb14211d55adc833f0826ae7e96ff5478e7e3e6Jeremy Sharpe	    conn.timeout = seconds * 1000;
737a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	}
741eb14211d55adc833f0826ae7e96ff5478e7e3e6Jeremy Sharpe	// END android-changed
75417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
76417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
77417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public int getQueryTimeout() throws SQLException {
781eb14211d55adc833f0826ae7e96ff5478e7e3e6Jeremy Sharpe	return conn.timeout / 1000; // android-changed: should return seconds
79417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
80417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
81417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public ResultSet getResultSet() throws SQLException {
827a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	return rs;
83417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
84417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
85417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    ResultSet executeQuery(String sql, String args[], boolean updonly)
867a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	throws SQLException {
877a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	SQLite.TableResult tr = null;
887a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	if (rs != null) {
897a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	    rs.close();
907a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	    rs = null;
917a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	}
927a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	updcnt = -1;
937a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	if (conn == null || conn.db == null) {
947a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	    throw new SQLException("stale connection");
957a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	}
967a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	int busy = 0;
977a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	boolean starttrans = !conn.autocommit && !conn.intrans;
987a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	while (true) {
997a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	    try {
1007a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		if (starttrans) {
1017a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		    conn.db.exec("BEGIN TRANSACTION", null);
1027a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		    conn.intrans = true;
1037a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		}
1047a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		if (args == null) {
1057a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		    if (updonly) {
1067a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes			conn.db.exec(sql, null);
1077a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		    } else {
1087a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes			tr = conn.db.get_table(sql, maxrows);
1097a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		    }
1107a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		} else {
1117a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		    if (updonly) {
1127a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes			conn.db.exec(sql, null, args);
1137a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		    } else {
1147a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes			tr = conn.db.get_table(sql, maxrows, args);
1157a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		    }
1167a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		}
1177a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		updcnt = (int) conn.db.changes();
1187a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	    } catch (SQLite.Exception e) {
1197a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		if (conn.db.is3() &&
1207a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		    conn.db.last_error() == SQLite.Constants.SQLITE_BUSY &&
1217a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		    conn.busy3(conn.db, ++busy)) {
1227a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		    try {
1237a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes			if (starttrans && conn.intrans) {
1247a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes			    conn.db.exec("ROLLBACK", null);
1257a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes			    conn.intrans = false;
1267a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes			}
1277a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		    } catch (SQLite.Exception ee) {
1287a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		    }
1297a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		    try {
1307a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes			int ms = 20 + busy * 10;
1317a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes			if (ms > 1000) {
1327a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes			    ms = 1000;
1337a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes			}
1347a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes			synchronized (this) {
1357a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes			    this.wait(ms);
1367a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes			}
1377a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		    } catch (java.lang.Exception eee) {
1387a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		    }
1397a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		    continue;
1407a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		}
1417a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		throw new SQLException(e.toString());
1427a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	    }
1437a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	    break;
1447a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	}
1457a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	if (!updonly && tr == null) {
1467a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	    throw new SQLException("no result set produced");
1477a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	}
1487a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	if (!updonly && tr != null) {
1497a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	    rs = new JDBCResultSet(new TableResultX(tr), this);
1507a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	}
1517a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	return rs;
152417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
153417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
154417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public ResultSet executeQuery(String sql) throws SQLException {
1557a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	return executeQuery(sql, null, false);
156417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
157417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
158417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public boolean execute(String sql) throws SQLException {
1597a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	return executeQuery(sql) != null;
160417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
161417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
162417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public void cancel() throws SQLException {
1637a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	if (conn == null || conn.db == null) {
1647a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	    throw new SQLException("stale connection");
1657a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	}
1667a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	conn.db.interrupt();
167417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
168417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
169417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public void clearWarnings() throws SQLException {
170417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
171417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
172417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public Connection getConnection() throws SQLException {
1737a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	return conn;
174417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
175417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
176417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public void addBatch(String sql) throws SQLException {
1777a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	if (batch == null) {
1787a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	    batch = new ArrayList<String>(1);
1797a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	}
1807a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	batch.add(sql);
181417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
182417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
183417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public int[] executeBatch() throws SQLException {
1847a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	if (batch == null) {
1857a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	    return new int[0];
1867a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	}
1877a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	int[] ret = new int[batch.size()];
1887a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	for (int i = 0; i < ret.length; i++) {
1897a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	    ret[i] = EXECUTE_FAILED;
1907a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	}
1917a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	int errs = 0;
1927a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	for (int i = 0; i < ret.length; i++) {
1937a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	    try {
1947a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		execute((String) batch.get(i));
1957a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		ret[i] = updcnt;
1967a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	    } catch (SQLException e) {
1977a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes		++errs;
1987a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	    }
1997a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	}
2007a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	if (errs > 0) {
2017a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	    throw new BatchUpdateException("batch failed", ret);
2027a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	}
2037a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	return ret;
204417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
205417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
206417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public void clearBatch() throws SQLException {
2077a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	if (batch != null) {
2087a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	    batch.clear();
2097a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	    batch = null;
2107a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	}
211417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
212417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
213417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public void close() throws SQLException {
2147a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	clearBatch();
2157a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	conn = null;
216417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
217417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
218417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public int executeUpdate(String sql) throws SQLException {
2197a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	executeQuery(sql, null, true);
2207a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	return updcnt;
221417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
222417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
223417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public int getMaxFieldSize() throws SQLException {
2247a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	return 0;
225417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
226417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
227417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public boolean getMoreResults() throws SQLException {
2287a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	if (rs != null) {
2297a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	    rs.close();
2307a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	    rs = null;
2317a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	}
2327a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	return false;
233417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
234417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
235417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public int getUpdateCount() throws SQLException {
2367a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	return updcnt;
237417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
238417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
239417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public SQLWarning getWarnings() throws SQLException {
2407a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	return null;
241417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
242417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
243417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public void setCursorName(String name) throws SQLException {
24417c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe	throw new SQLFeatureNotSupportedException();
245417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
246417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
247417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public void setEscapeProcessing(boolean enable) throws SQLException {
2487a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	throw new SQLException("not supported");
249417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
250417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
251417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public void setMaxFieldSize(int max) throws SQLException {
2527a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	throw new SQLException("not supported");
253417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
254417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
255417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public boolean getMoreResults(int x) throws SQLException {
25617c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe	throw new SQLFeatureNotSupportedException();
257417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
258417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
259417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public ResultSet getGeneratedKeys() throws SQLException {
26017c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe	throw new SQLFeatureNotSupportedException();
261417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
262417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
263417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public int executeUpdate(String sql, int autokeys)
2647a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	throws SQLException {
2657a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	if (autokeys != Statement.NO_GENERATED_KEYS) {
26617c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe	    throw new SQLFeatureNotSupportedException("generated keys not supported");
2677a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	}
2687a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	return executeUpdate(sql);
269417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
270417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
271417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public int executeUpdate(String sql, int colIndexes[])
2727a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	throws SQLException {
27317c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe	throw new SQLFeatureNotSupportedException();
274417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
275417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
276417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public int executeUpdate(String sql, String colIndexes[])
2777a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	throws SQLException {
27817c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe	throw new SQLFeatureNotSupportedException();
279417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
280417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
281417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public boolean execute(String sql, int autokeys)
2827a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	throws SQLException {
2837a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	if (autokeys != Statement.NO_GENERATED_KEYS) {
28417c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe	    throw new SQLFeatureNotSupportedException("autogenerated keys not supported");
2857a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	}
2867a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	return execute(sql);
287417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
288417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
289417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public boolean execute(String sql, int colIndexes[])
2907a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	throws SQLException {
29117c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe	throw new SQLFeatureNotSupportedException();
292417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
293417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
294417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public boolean execute(String sql, String colIndexes[])
2957a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	throws SQLException {
29617c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe	throw new SQLFeatureNotSupportedException();
297417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
298417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
299417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public int getResultSetHoldability() throws SQLException {
3007a647e8547e57ca573541be55b3728ef7ce376feElliott Hughes	return ResultSet.HOLD_CURSORS_OVER_COMMIT;
301417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    }
302417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
30317c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe    public boolean isClosed() throws SQLException {
3041eb14211d55adc833f0826ae7e96ff5478e7e3e6Jeremy Sharpe	return conn == null; // android-changed: pretty sure this is correct, since it matches what's done in close()
30517c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe    }
30617c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe
30717c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe    public void setPoolable(boolean yes) throws SQLException {
30817c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe	if (yes) {
30917c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe	    throw new SQLException("poolable statements not supported");
31017c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe	}
31117c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe    }
31217c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe
31317c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe    public boolean isPoolable() throws SQLException {
31417c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe	return false;
31517c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe    }
31617c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe
31717c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe    public <T> T unwrap(java.lang.Class<T> iface) throws SQLException {
31817c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe	throw new SQLException("unsupported");
31917c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe    }
32017c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe
32117c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe    public boolean isWrapperFor(java.lang.Class iface) throws SQLException {
32217c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe	return false;
32317c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe    }
32417c83b1a74c906c9a36257a3a99cd1e3730b002eJeremy Sharpe
325417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes}
326