Changeset: 2ad7f42f141d for monetdb-java
URL: https://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=2ad7f42f141d
Added Files:
        tests/Bug_LargeQueries_6571_6693.java
Removed Files:
        src/main/java/nl/cwi/monetdb/mcl/connection/SenderThread.java
Modified Files:
        src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in
        src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetSavepoint.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java
        tests/build.xml
Branch: embedded
Log Message:

Merge with default.


diffs (truncated from 4428 to 300 lines):

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
@@ -11,7 +11,6 @@ package nl.cwi.monetdb.jdbc;
 import nl.cwi.monetdb.mcl.connection.ControlCommands;
 import nl.cwi.monetdb.mcl.connection.IMonetDBLanguage;
 import nl.cwi.monetdb.mcl.connection.MCLException;
-import nl.cwi.monetdb.mcl.connection.SenderThread;
 import nl.cwi.monetdb.mcl.protocol.AbstractProtocol;
 import nl.cwi.monetdb.mcl.protocol.ProtocolException;
 import nl.cwi.monetdb.mcl.protocol.ServerResponses;
@@ -50,8 +49,10 @@ import java.util.concurrent.Executor;
  * @author Fabian Groffen, Martin van Dinther, Pedro Ferreira
  * @version 1.3
  */
-public abstract class MonetConnection extends MonetWrapper implements 
Connection, AutoCloseable {
-
+public abstract class MonetConnection
+               extends MonetWrapper
+               implements Connection, AutoCloseable
+{
        /** The sequence counter */
        private static int SeqCounter = 0;
 
@@ -66,18 +67,22 @@ public abstract class MonetConnection ex
 
        /** The successful processed input properties */
        protected final Properties conn_props;
+
        /** The language to connect with */
        protected IMonetDBLanguage language;
+
        /** Authentication hash method */
        protected final String hash;
-       /** An optional thread that is used for sending large queries */
-       private SenderThread senderThread;
+
        /** Whether this Connection is closed (and cannot be used anymore) */
        private boolean closed;
+
        /** Whether this Connection is in autocommit mode */
        private boolean autoCommit = true;
+
        /** The stack of warnings for this Connection object */
-       private SQLWarning warnings;
+       private SQLWarning warnings = null;
+
        /** The Connection specific mapping of user defined types to Java types 
*/
        private Map<String,Class<?>> typeMap = new HashMap<String,Class<?>>() {
                private static final long serialVersionUID = 1L; {
@@ -86,25 +91,32 @@ public abstract class MonetConnection ex
                }
        };
 
-       // See javadoc for documentation about WeakHashMap if you don't know 
what it does !!!NOW!!!
-       // (only when you deal with it of course)
+       // See javadoc for documentation about WeakHashMap if you don't know 
what
+       // it does !!!NOW!!! (only when you deal with it of course)
        /** A Map containing all (active) Statements created from this 
Connection */
-       private Map<Statement,?> statements = new WeakHashMap<>();
+       private Map<Statement,?> statements = new WeakHashMap<Statement, 
Object>();
+
        /** The number of results we receive from the server at once */
-       private int curReplySize = -1; // the server by default uses -1 (all)
+       private int curReplySize = -1;  // the server by default uses -1 (all)
        /** Whether or not BLOB is mapped to Types.VARBINARY instead of 
Types.BLOB within this connection */
-       private final boolean treatBlobAsVarBinary;
+       private boolean treatBlobAsVarBinary = false;
        /** Whether or not CLOB is mapped to Types.VARCHAR instead of 
Types.CLOB within this connection */
-       private final boolean treatClobAsVarChar;
+       private boolean treatClobAsVarChar = false;
        /** The underlying proticol provided by the connection (MAPI or 
embedded) */
        protected AbstractProtocol protocol;
        /** Tells if the connection is embedded or not */
        private final boolean isEmbedded;
 
        /**
-        * Constructor of a Connection for MonetDB. At this moment the current 
implementation limits itself to storing the
-        * given host, database, username and password for later use by the 
createStatement() call.  This constructor is
-        * only accessible to classes from the jdbc package.
+        * Constructor of a Connection for MonetDB. At this moment the
+        * current implementation limits itself to storing the given host,
+        * database, username and password for later use by the
+        * createStatement() call.  This constructor is only accessible to
+        * classes from the jdbc package.
+        *
+        * @param props a Property hashtable holding the properties needed for 
connecting
+        * @throws SQLException if a database error occurs
+        * @throws IllegalArgumentException is one of the arguments is null or 
empty
         */
        public MonetConnection(Properties props, String hash, IMonetDBLanguage 
language, boolean blobIsBinary,
                                                   boolean clobIsLongChar) {
@@ -181,6 +193,7 @@ public abstract class MonetConnection ex
        /** The last set query timeout on the server as used by Statement, 
PreparedStatement and CallableStatement */
        protected int lastSetQueryTimeout = 0;  // 0 means no timeout, which is 
the default on the server
 
+
        /**
         * Gets the initial value for the StringBuilder size.
         *
@@ -239,10 +252,23 @@ public abstract class MonetConnection ex
                                                                                
                         BatchUpdateException e) throws SQLException;
 
        /**
-        * Releases this Connection object's database and JDBC resources 
immediately instead of waiting for them to be
-        * automatically released. All Statements created from this Connection 
will be closed when this method is called.
+        * Clears all warnings reported for this Connection object. After a
+        * call to this method, the method getWarnings returns null until a
+        * new warning is reported for this Connection object.
+        */
+       @Override
+       public void clearWarnings() {
+               warnings = null;
+       }
+
+       /**
+        * Releases this Connection object's database and JDBC resources
+        * immediately instead of waiting for them to be automatically
+        * released. All Statements created from this Connection will be
+        * closed when this method is called.
         *
-        * Calling the method close on a Connection object that is already 
closed is a no-op.
+        * Calling the method close on a Connection object that is already
+        * closed is a no-op.
         */
        @Override
        public void close() {
@@ -259,11 +285,6 @@ public abstract class MonetConnection ex
                } catch (IOException e) {
                        // ignore it
                }
-               // close active SendThread if any
-               if (senderThread != null) {
-                       senderThread.shutdown();
-                       senderThread = null;
-               }
                // report ourselves as closed
                closed = true;
        }
@@ -278,28 +299,21 @@ public abstract class MonetConnection ex
                super.finalize();
        }
 
-       //== methods of interface Connection
-
        /**
-        * Clears all warnings reported for this Connection object. After a 
call to this method, the method getWarnings
-        * returns null until a new warning is reported for this Connection 
object.
-        */
-       @Override
-       public void clearWarnings() {
-               warnings = null;
-       }
-
-       /**
-        * Makes all changes made since the previous commit/rollback permanent 
and releases any database locks currently
-        * held by this Connection object. This method should be used only when 
auto-commit mode has been disabled.
+        * Makes all changes made since the previous commit/rollback
+        * permanent and releases any database locks currently held by this
+        * Connection object.  This method should be used only when
+        * auto-commit mode has been disabled.
         *
-        * @throws SQLException if a database access error occurs or this 
Connection object is in auto-commit mode
+        * @throws SQLException if a database access error occurs or this
+        *         Connection object is in auto-commit mode
         * @see #setAutoCommit(boolean)
         */
        @Override
        public void commit() throws SQLException {
-               // note: can't use sendIndependentCommand here because we need 
to process the auto_commit state the server gives
-               this.sendTransactionCommand("COMMIT");
+               // note: can't use sendIndependentCommand here because we need
+               // to process the auto_commit state the server gives
+               sendTransactionCommand("COMMIT");
        }
 
        /**
@@ -400,9 +414,12 @@ public abstract class MonetConnection ex
        }
 
        /**
-        * Retrieves the current holdability of ResultSet objects created using 
this Connection object.
+        * Retrieves the current holdability of ResultSet objects created
+        * using this Connection object.
         *
-        * @return the holdability, one of ResultSet.HOLD_CURSORS_OVER_COMMIT 
or ResultSet.CLOSE_CURSORS_AT_COMMIT
+        * @return the holdability, one of
+        *         ResultSet.HOLD_CURSORS_OVER_COMMIT or
+        *         ResultSet.CLOSE_CURSORS_AT_COMMIT
         * @see #setHoldability(int)
         */
        @Override
@@ -424,16 +441,18 @@ public abstract class MonetConnection ex
         */
        @Override
        public DatabaseMetaData getMetaData() throws SQLException {
-               if (!this.language.getRepresentation().equals("sql")) {
+               if (!this.language.getRepresentation().equals("sql"))
                        throw new SQLException("This method is only supported 
in SQL mode", "M0M04");
-               }
+
                return new MonetDatabaseMetaData(this);
        }
 
        /**
-        * Retrieves this Connection object's current transaction isolation 
level.
+        * Retrieves this Connection object's current transaction isolation
+        * level.
         *
-        * @return the current transaction isolation level, which will be 
Connection.TRANSACTION_SERIALIZABLE
+        * @return the current transaction isolation level, which will be
+        *         Connection.TRANSACTION_SERIALIZABLE
         */
        @Override
        public int getTransactionIsolation() {
@@ -441,10 +460,12 @@ public abstract class MonetConnection ex
        }
 
        /**
-        * Retrieves the Map object associated with this Connection object. 
Unless the application has added an entry,
-        * the type map returned will be empty.
+        * Retrieves the Map object associated with this Connection object.
+        * Unless the application has added an entry, the type map returned
+        * will be empty.
         *
-        * @return the java.util.Map object associated with this Connection 
object
+        * @return the java.util.Map object associated with this Connection
+        *         object
         */
        @Override
        public Map<String,Class<?>> getTypeMap() {
@@ -458,19 +479,22 @@ public abstract class MonetConnection ex
         * the method SQLWarning.getNextWarning on the warning that was
         * retrieved previously.
         *
-        * This method may not be called on a closed connection; doing so will 
cause an SQLException to be thrown.
+        * This method may not be called on a closed connection; 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
-        * @throws SQLException if a database access error occurs or this 
method is called on a closed connection
+        * @throws SQLException if a database access error occurs or this 
method is
+        *         called on a closed connection
         */
        @Override
        public SQLWarning getWarnings() throws SQLException {
-               if (closed) {
+               if (closed)
                        throw new SQLException("Cannot call on closed 
Connection", "M1M20");
-               }
-               // if there are no warnings, this will be null, which fits with 
the specification.
+
+               // if there are no warnings, this will be null, which fits with 
the
+               // specification.
                return warnings;
        }
 
@@ -486,7 +510,8 @@ public abstract class MonetConnection ex
         * can determine that a connection is invalid by catching any
         * exceptions that might be thrown when an operation is attempted.
         *
-        * @return true if this Connection object is closed; false if it is 
still open
+        * @return true if this Connection object is closed; false if it is
+        *         still open
         */
        @Override
        public boolean isClosed() {
@@ -688,10 +713,16 @@ public abstract class MonetConnection ex
         */
        @Override
        public PreparedStatement prepareStatement(String sql, int 
resultSetType, int resultSetConcurrency, int resultSetHoldability)
-                       throws SQLException {
+               throws SQLException
+       {
                try {
-                       PreparedStatement ret = new 
MonetPreparedStatement(this, resultSetType, resultSetConcurrency,
-                                       resultSetHoldability, sql);
+                       PreparedStatement ret = new MonetPreparedStatement(
+                               this,
+                               resultSetType,
+                               resultSetConcurrency,
+                               resultSetHoldability,
+                               sql
+                       );
                        // store it in the map for when we close...
                        statements.put(ret, null);
                        return ret;
@@ -814,20 +845,20 @@ public abstract class MonetConnection ex
         */
        @Override
        public void releaseSavepoint(Savepoint savepoint) throws SQLException {
-               if (!(savepoint instanceof MonetSavepoint)) {
+               if (!(savepoint instanceof MonetSavepoint))
                        throw new SQLException("This driver can only handle 
savepoints it created itself", "M0M06");
-               }
-               MonetSavepoint sp = (MonetSavepoint) savepoint;
+
+               MonetSavepoint sp = (MonetSavepoint)savepoint;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to