diff src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java @ 29:c26213e86442

Use newSQLFeatureNotSupportedException() for setArray() Beautifying code layout and indentation.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Thu, 27 Oct 2016 15:54:13 +0200 (2016-10-27)
parents 3fa949cbc783
children e605cdd6373f b9b35ca2eec2
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
@@ -22,17 +22,17 @@ import java.util.concurrent.locks.Reentr
 
 /**
  * A Statement suitable for the MonetDB database.
- * 
+ *
  * The object used for executing a static SQL statement and returning
  * the results it produces.<br />
- * 
+ *
  * By default, only one {@link ResultSet} object per Statement object can be
  * open at the same time. Therefore, if the reading of one ResultSet
  * object is interleaved with the reading of another, each must have
  * been generated by different {@link Statement} objects. All execution methods
  * in the Statement interface implicitly close a Statement's current
  * ResultSet object if an open one exists.
- * 
+ *
  * The current state of this Statement is that it only implements the
  * executeQuery() which returns a ResultSet where from results can be
  * read and executeUpdate() which doesn't return the affected rows.
@@ -41,6 +41,7 @@ import java.util.concurrent.locks.Reentr
  * Multi-result queries are supported using the getMoreResults() method.
  *
  * @author Fabian Groffen
+ * @author Martin van Dinther
  * @version 0.7
  */
 public class MonetStatement extends MonetWrapper implements Statement {
@@ -147,7 +148,7 @@ public class MonetStatement extends Mone
 	}
 
 	Lock batchLock = new ReentrantLock();
-	
+
 	/**
 	 * Submits a batch of commands to the database for execution and if
 	 * all commands execute successfully, returns an array of update
@@ -284,7 +285,7 @@ public class MonetStatement extends Mone
 	}
 
 	/**
-     * Cancels this Statement object if both the DBMS and driver support
+	 * Cancels this Statement object if both the DBMS and driver support
 	 * aborting an SQL statement.  This method can be used by one thread to
 	 * cancel a statement that is being executed by another thread.
 	 *
@@ -322,7 +323,8 @@ public class MonetStatement extends Mone
 	@Override
 	public void close() {
 		// close previous ResultSet, if not closed already
-		if (lastResponseList != null) lastResponseList.close();
+		if (lastResponseList != null)
+			lastResponseList.close();
 		closed = true;
 	}
 
@@ -349,7 +351,7 @@ public class MonetStatement extends Mone
 	public boolean execute(String sql) throws SQLException {
 		return internalExecute(sql);
 	}
-	
+
 	/**
 	 * Executes the given SQL statement, which may return multiple
 	 * results, and signals the driver that any auto-generated keys
@@ -385,11 +387,10 @@ public class MonetStatement extends Mone
 		throws SQLException
 	{
 		if (autoGeneratedKeys != Statement.RETURN_GENERATED_KEYS &&
-				autoGeneratedKeys != Statement.NO_GENERATED_KEYS)
+		    autoGeneratedKeys != Statement.NO_GENERATED_KEYS)
 			throw new SQLException("Invalid argument, expected RETURN_GENERATED_KEYS or NO_GENERATED_KEYS", "M1M05");
-		
-		/* MonetDB has no way to disable this, so just do the normal
-		 * thing ;) */
+
+		/* MonetDB has no way to disable this, so just do the normal thing ;) */
 		return internalExecute(sql);
 	}
 
@@ -576,11 +577,10 @@ public class MonetStatement extends Mone
 		throws SQLException
 	{
 		if (autoGeneratedKeys != Statement.RETURN_GENERATED_KEYS &&
-				autoGeneratedKeys != Statement.NO_GENERATED_KEYS)
+		    autoGeneratedKeys != Statement.NO_GENERATED_KEYS)
 			throw new SQLException("Invalid argument, expected RETURN_GENERATED_KEYS or NO_GENERATED_KEYS", "M1M05");
-		
-		/* MonetDB has no way to disable this, so just do the normal
-		 * thing ;) */
+
+		/* MonetDB has no way to disable this, so just do the normal thing ;) */
 		if (execute(sql) != false)
 			throw new SQLException("Query produced a result set", "M1M17");
 
@@ -706,7 +706,7 @@ public class MonetStatement extends Mone
 		types = new String[1];
 
 		columns[0] = "GENERATED_KEY";
-		/* the generated key should be an integer, because (wait for it) other 
+		/* the generated key should be an integer, because (wait for it) other
 		 * frameworks such as spring expect this. */
 		types[0] = "BIGINT";
 
@@ -745,9 +745,7 @@ public class MonetStatement extends Mone
 	 * @throws SQLException if a database access error occurs
 	 */
 	@Override
-	public int getMaxFieldSize()
-		throws SQLException
-	{
+	public int getMaxFieldSize() {
 		return 0;
 	}
 
@@ -814,11 +812,7 @@ public class MonetStatement extends Mone
 		// we default to keep current result, which requires no action
 		header = lastResponseList.getNextResponse();
 
-		if (header instanceof MonetConnection.ResultSetResponse) {
-			return true;
-		} else {
-			return false;
-		}
+		return (header instanceof MonetConnection.ResultSetResponse);
 	}
 
 	/**
@@ -864,7 +858,7 @@ public class MonetStatement extends Mone
 	 * @throws SQLException if a database access error occurs
 	 */
 	@Override
-	public ResultSet getResultSet() throws SQLException{
+	public ResultSet getResultSet() throws SQLException {
 		return (header instanceof MonetConnection.ResultSetResponse)
 			? new MonetResultSet(this,
 					(MonetConnection.ResultSetResponse)header)
@@ -1024,7 +1018,7 @@ public class MonetStatement extends Mone
 	public void setFetchDirection(int direction) throws SQLException {
 		if (direction == ResultSet.FETCH_FORWARD ||
 		    direction == ResultSet.FETCH_REVERSE ||
-			direction == ResultSet.FETCH_UNKNOWN)
+		    direction == ResultSet.FETCH_UNKNOWN)
 		{
 			fetchDirection = direction;
 		} else {
@@ -1169,7 +1163,7 @@ public class MonetStatement extends Mone
 	}
 
 	//== 1.7 methods (JDBC 4.1)
-	
+
 	/**
 	 * Specifies that this Statement will be closed when all its
 	 * dependent result sets are closed.  If execution of the Statement