Mercurial > hg > monetdb-java
changeset 13:749e3cf8b2aa
Expanded the classes needed for import.
Removed trailing spaces on text lines.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 29 Sep 2016 20:48:10 +0200 (2016-09-29) |
parents | a0e8adf10d41 |
children | 3fa949cbc783 |
files | src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java |
diffstat | 1 files changed, 46 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java +++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java @@ -8,13 +8,18 @@ package nl.cwi.monetdb.jdbc; -import java.sql.*; -import java.util.*; +import nl.cwi.monetdb.mcl.net.MapiSocket; +import java.sql.BatchUpdateException; +import java.sql.Connection; +import java.sql.Statement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; -import nl.cwi.monetdb.mcl.net.*; - /** * A Statement suitable for the MonetDB database. * @@ -167,7 +172,7 @@ public class MonetStatement extends Mone * in the batch. However, the driver's behavior must be consistent * with a particular DBMS, either always continuing to process * commands or never continuing to process commands. - * + * * MonetDB does continues after an error has occurred in the batch. * If one of the commands attempts to return a result set, an * SQLException is added to the SQLException list and thrown @@ -190,7 +195,7 @@ public class MonetStatement extends Mone batchLock.lock(); try { // don't think long if there isn't much to do - if (batch.isEmpty()) + if (batch.isEmpty()) return new int[0]; int[] counts = new int[batch.size()]; @@ -306,10 +311,10 @@ public class MonetStatement extends Mone * instead of waiting for this to happen when it is automatically closed. It * is generally good practice to release resources as soon as you are * finished with them to avoid tying up database resources. - * + * * Calling the method close on a Statement object that is already closed has * no effect. - * + * * A Statement object is automatically closed when it is garbage collected. * When a Statement object is closed, its current ResultSet object, if one * exists, is also closed. @@ -329,7 +334,7 @@ public class MonetStatement extends Mone * you are (1) executing a stored procedure that you know may return * multiple results or (2) you are dynamically executing an unknown SQL * string. - * + * * The execute method executes an SQL statement and indicates the form of * the first result. You must then use the methods getResultSet or * getUpdateCount to retrieve the result, and getMoreResults to move to any @@ -350,17 +355,17 @@ public class MonetStatement extends Mone * results, and signals the driver that any auto-generated keys * should be made available for retrieval. The driver will ignore * this signal if the SQL statement is not an INSERT statement. - * + * * In some (uncommon) situations, a single SQL statement may return * multiple result sets and/or update counts. Normally you can * ignore this unless you are (1) executing a stored procedure that * you know may return multiple results or (2) you are dynamically * executing an unknown SQL string. - * + * * The execute method executes an SQL statement and indicates the * form of the first result. You must then use the methods * getResultSet or getUpdateCount to retrieve the result, and - * getMoreResults to move to any subsequent result(s). + * getMoreResults to move to any subsequent result(s). * * @param sql any SQL statement * @param autoGeneratedKeys a constant indicating whether @@ -396,24 +401,24 @@ public class MonetStatement extends Mone * target table that contain the auto-generated keys that should be * made available. The driver will ignore the array if the given SQL * statement is not an INSERT statement. - * + * * Under some (uncommon) situations, a single SQL statement may * return multiple result sets and/or update counts. Normally you * can ignore this unless you are (1) executing a stored procedure * that you know may return multiple results or (2) you are * dynamically executing an unknown SQL string. - * + * * The execute method executes an SQL statement and indicates the * form of the first result. You must then use the methods * getResultSet or getUpdateCount to retrieve the result, and * getMoreResults to move to any subsequent result(s). - * + * * MonetDB only supports returing the generated key for one column, * which will be the first column that has a serial. Hence, this * method cannot work as required and the driver will fall back to * executing with request to the database to return the generated * key, if any. - * + * * @param sql any SQL statement * @param columnIndexes an array of the indexes of the columns in * the inserted row that should be made available for @@ -440,18 +445,18 @@ public class MonetStatement extends Mone * target table that contain the auto-generated keys that should be * made available. The driver will ignore the array if the given SQL * statement is not an INSERT statement. - * + * * In some (uncommon) situations, a single SQL statement may return * multiple result sets and/or update counts. Normally you can * ignore this unless you are (1) executing a stored procedure that * you know may return multiple results or (2) you are dynamically * executing an unknown SQL string. - * + * * The execute method executes an SQL statement and indicates the * form of the first result. You must then use the methods * getResultSet or getUpdateCount to retrieve the result, and * getMoreResults to move to any subsequent result(s). - * + * * MonetDB only supports returing the generated key for one column, * which will be the first column that has a serial. Hence, this * method cannot work as required and the driver will fall back to @@ -587,7 +592,7 @@ public class MonetStatement extends Mone * auto-generated keys indicated in the given array should be made * available for retrieval. The driver will ignore the array if the * SQL statement is not an INSERT statement. - * + * * MonetDB only supports returing the generated key for one column, * which will be the first column that has a serial. Hence, this * method cannot work as required and the driver will fall back to @@ -618,7 +623,7 @@ public class MonetStatement extends Mone * auto-generated keys indicated in the given array should be made * available for retrieval. The driver will ignore the array if the * SQL statement is not an INSERT statement. - * + * * MonetDB only supports returing the generated key for one column, * which will be the first column that has a serial. Hence, this * method cannot work as required and the driver will fall back to @@ -731,7 +736,7 @@ public class MonetStatement extends Mone * VARBINARY, LONGVARBINARY, CHAR, VARCHAR, and LONGVARCHAR * columns. If the limit is exceeded, the excess data is silently * discarded. - * + * * The MonetDB JDBC driver currently doesn't support limiting * fieldsizes, and hence always return 0 (unlimited). * @@ -763,7 +768,7 @@ public class MonetStatement extends Mone * Moves to this Statement object's next result, returns true if it is a * ResultSet object, and implicitly closes any current ResultSet object(s) * obtained with the method getResultSet. - * + * * There are no more results when the following is true:<br /> * (!getMoreResults() && (getUpdateCount() == -1) * @@ -781,7 +786,7 @@ public class MonetStatement extends Mone * Moves to this Statement object's next result, deals with any current * ResultSet object(s) according to the instructions specified by the given * flag, and returns true if the next result is a ResultSet object. - * + * * There are no more results when the following is true:<br /> * (!getMoreResults() && (getUpdateCount() == -1) * @@ -820,12 +825,12 @@ public class MonetStatement extends Mone * Retrieves the number of seconds the driver will wait for a * Statement object to execute. If the limit is exceeded, a * SQLException is thrown. - * + * * For MonetDB this method always returns zero, as no query * cancelling is possible. * * @return the current query timeout limit in seconds; zero means - * there is no limit + * there is no limit * @throws SQLException if a database access error occurs * @see #setQueryTimeout(int) */ @@ -844,7 +849,7 @@ public class MonetStatement extends Mone */ @Override public ResultSet getResultSet() throws SQLException{ - return (header instanceof MonetConnection.ResultSetResponse) + return (header instanceof MonetConnection.ResultSetResponse) ? new MonetResultSet(this, (MonetConnection.ResultSetResponse)header) : null; @@ -913,10 +918,10 @@ public class MonetStatement extends Mone * If there is more than one warning, subsequent warnings will be chained to * the first one and can be retrieved by calling the method * SQLWarning.getNextWarning on the warning that was retrieved previously. - * + * * This method may not be called on a closed statement; doing so will cause * an SQLException to be thrown. - * + * * Note: Subsequent warnings will be chained to this SQLWarning. * * @return the first SQLWarning object or null if there are none @@ -943,13 +948,13 @@ public class MonetStatement extends Mone * the proper isolation level to support updates, the cursor's * SELECT statement should have the form SELECT FOR UPDATE. If FOR * UPDATE is not present, positioned updates may fail. - * + * * <b>Note:</b> By definition, the execution of positioned updates * and deletes must be done by a different Statement object than the * one that generated the ResultSet object being used for * positioning. Also, cursor names must be unique within a - * connection. - * + * connection. + * * Since MonetDB does not support positioned update/delete, this * method is a noop. * @@ -969,7 +974,7 @@ public class MonetStatement extends Mone * statements have usually been parsed prior to making this call, * disabling escape processing for PreparedStatements objects will * have no effect. - * + * * The MonetDB JDBC driver implements no escape processing at all in * its current implementation because it is too expensive, and in * general should not be necessary given SQL standards compliance. @@ -989,7 +994,7 @@ public class MonetStatement extends Mone * Gives the driver a hint as to the direction in which rows will be * processed in ResultSet objects created using this Statement object. * The default value is ResultSet.FETCH_FORWARD. - * + * * Note that this method sets the default fetch direction for result sets * generated by this Statement object. Each result set has its own methods * for getting and setting its own fetch direction. @@ -1037,7 +1042,7 @@ public class MonetStatement extends Mone * LONGVARBINARY, CHAR, VARCHAR, and LONGVARCHAR fields. If the * limit is exceeded, the excess data is silently discarded. For * maximum portability, use values greater than 256. - * + * * MonetDB does not support any fieldsize limiting, and hence the * driver does not emulate it either, since it doesn't really lead * to memory reduction. @@ -1074,7 +1079,7 @@ public class MonetStatement extends Mone * Sets the number of seconds the driver will wait for a Statement * object to execute to the given number of seconds. If the limit is * exceeded, an SQLException is thrown. - * + * * MonetDB does not support cancelling running queries, hence this * method does not do anything. * @@ -1111,12 +1116,12 @@ public class MonetStatement extends Mone * specified is a hint to the statement pool implementation * indicating whether the applicaiton wants the statement to be * pooled. It is up to the statement pool manager as to whether the - * hint is used. - * + * hint is used. + * * The poolable value of a statement is applicable to both internal * statement caches implemented by the driver and external statement * caches implemented by application servers and other applications. - * + * * By default, a Statement is not poolable when created, and a * PreparedStatement and CallableStatement are poolable when * created. @@ -1216,7 +1221,7 @@ public class MonetStatement extends Mone * * TODO: try to eliminate the need for this class completely. */ -class MonetVirtualResultSet extends MonetResultSet { +final class MonetVirtualResultSet extends MonetResultSet { private String results[][]; private boolean closed; @@ -1243,7 +1248,7 @@ class MonetVirtualResultSet extends Mone * @return true if the cursor is on the result set; false otherwise * @throws SQLException if a database error occurs */ - @Override + @Override public boolean absolute(int row) throws SQLException { if (closed) throw new SQLException("ResultSet is closed!", "M1M20");