# HG changeset patch
# User Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
# Date 1504797341 -7200
# Node ID 7c9e386fe49a35aefd416a493e67ff84d6e65bf1
# Parent  e398c27acf7eb38fddbb2825794a6e2b6d75efa0
As of Java 1.7 implementations of JDBC interfaces Connection, Statement, PreparedStatement,
 CallableStatement and ResulSet must implement the AutoCloseable interface with method close().
This method is invoked automatically on objects managed by the try-with-resources statement.

See http://docs.oracle.com/javase/7/docs/technotes/guides/language/try-with-resources.html
http://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.html
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html
http://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html
http://docs.oracle.com/javase/7/docs/api/java/sql/PreparedStatement.html
http://docs.oracle.com/javase/7/docs/api/java/sql/CallableStatement.html
http://docs.oracle.com/javase/7/docs/api/java/sql/ResultSet.html

diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
@@ -72,7 +72,10 @@ import nl.cwi.monetdb.mcl.parser.StartOf
  * @author Martin van Dinther
  * @version 1.3
  */
-public class MonetConnection extends MonetWrapper implements Connection {
+public class MonetConnection
+	extends MonetWrapper
+	implements Connection, AutoCloseable
+{
 	/** the successful processed input properties */
 	private final Properties conn_props = new Properties();
 
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java b/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
@@ -66,7 +66,7 @@ import java.util.Map;
  */
 public class MonetPreparedStatement
 	extends MonetStatement
-	implements PreparedStatement
+	implements PreparedStatement, AutoCloseable
 {
 	private final String[] monetdbType;
 	private final int[] javaType;
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java b/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
@@ -66,7 +66,10 @@ import java.util.TimeZone;
  * @author Fabian Groffen, Martin van Dinther
  * @version 0.8
  */
-public class MonetResultSet extends MonetWrapper implements ResultSet {
+public class MonetResultSet
+	extends MonetWrapper
+	implements ResultSet, AutoCloseable
+{
 	// the following have default access modifier for the MonetVirtualResultSet subclass
 	/** The current line of the buffer split in columns */
 	final TupleLineParser tlp;
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java b/src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java
@@ -44,7 +44,10 @@ import java.util.concurrent.locks.Reentr
  * @author Martin van Dinther
  * @version 0.7
  */
-public class MonetStatement extends MonetWrapper implements Statement {
+public class MonetStatement
+	extends MonetWrapper
+	implements Statement, AutoCloseable
+{
 	/** the default value of maxRows, 0 indicates unlimited */
 	static final int DEF_MAXROWS = 0;
 
@@ -96,8 +99,8 @@ public class MonetStatement extends Mone
 		int resultSetHoldability)
 		throws SQLException, IllegalArgumentException
 	{
-		if (connection == null) throw
-			new IllegalArgumentException("No Connection given!");
+		if (connection == null)
+			throw new IllegalArgumentException("No Connection given!");
 
 		this.connection = connection;
 		this.resultSetType = resultSetType;
@@ -260,8 +263,8 @@ public class MonetStatement extends Mone
 			int count = -1;
 			if (!type) count = getUpdateCount();
 			do {
-				if (offset >= max) throw
-					new SQLException("Overflow: don't use multi statements when batching (" + max + ")", "M1M16");
+				if (offset >= max)
+					throw new SQLException("Overflow: don't use multi statements when batching (" + max + ")", "M1M16");
 				if (type) {
 					e.setNextException(
 						new SQLException("Batch query produced a ResultSet! " +