Changeset: ffdc7b0e102d for monetdb-java
URL: https://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=ffdc7b0e102d
Modified Files:
        ChangeLog
        release.txt
        src/main/java/nl/cwi/monetdb/jdbc/MonetCallableStatement.java
        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/MonetPreparedStatement.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java
Branch: default
Log Message:

Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 
8. This includes:
- adding 8 methods to MonetCallableStatement
- adding 2 methods to MonetDatabaseMetaData
- adding 3 methods to MonetPreparedStatement
- adding 4 methods to MonetResultSet
- adding 8 methods to MonetStatement
Some methods needs some more work, for instance getLargeUpdateCount(). This 
will be done in a separate checkin.


diffs (truncated from 775 to 300 lines):

diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,10 +2,20 @@
 # This file is updated with Maddlog
 
 * Wed Sep 23 2020 Martin van Dinther <martin.van.dint...@monetdbsolutions.com>
+- Updated JDBC driver to comply with JDBC 4.2 interface now we compile
+  for Java 8. This includes:
+  - adding 8 methods to MonetCallableStatement
+  - adding 2 methods to MonetDatabaseMetaData
+  - adding 3 methods to MonetPreparedStatement
+  - adding 4 methods to MonetResultSet
+  - adding 8 methods to MonetStatement
 - Corrected MonetDatabaseMetaData.getTypeInfo()
-  - The LITERAL_PREFIX column now includes the required casting name for 
types: clob, inet, json, url, uuid and blob.
-  - The SEARCHABLE column now returns typePredBasic instead of typeSearchable 
for type: blob.
-  - The AUTO_INCREMENT column now returns false for types: hugeint, decimal, 
oid and wrd.
+  - The LITERAL_PREFIX column now includes the required casting name for
+    types: clob, inet, json, url, uuid and blob.
+  - The SEARCHABLE column now returns typePredBasic instead of typeSearchable
+    for type: blob.
+  - The AUTO_INCREMENT column now returns false for types: hugeint, decimal,
+    oid and wrd.
 
 * Thu Sep 10 2020 Martin van Dinther <martin.van.dint...@monetdbsolutions.com>
 - Removed support for deprecated MD5 encryption algorithm in MapiSocket.
diff --git a/release.txt b/release.txt
--- a/release.txt
+++ b/release.txt
@@ -43,8 +43,8 @@ See also: https://www.monetdb.org/Docume
 
 JDBC COMPLIANCE
 The MonetDB JDBC driver is a type 4 driver (100% pure Java) and
-complies to JDBC 4.1 definition, see
- http://docs.oracle.com/javase/7/docs/technotes/guides/jdbc/index.html
+complies to JDBC 4.2 definition, see
+ http://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/index.html
 and
  https://en.wikipedia.org/wiki/Java_Database_Connectivity
 
@@ -60,7 +60,7 @@ If you feel some features are missing or
 please let us know at our bugtracker:
   https://www.monetdb.org/bugzilla/
 
-Currently implemented JDBC 4.1 interfaces include:
+Currently implemented JDBC 4.2 interfaces include:
   * java.sql.Driver
 
   * java.sql.Connection
@@ -138,11 +138,13 @@ Currently implemented JDBC 4.1 interface
 
 The following java.sql.* interfaces are NOT implemented:
   * java.sql.Array
+  * java.sql.DriverAction
   * java.sql.NClob
   * java.sql.Ref
   * java.sql.Rowid
   * java.sql.SQLInput
   * java.sql.SQLOutput
+  * java.sql.SQLType
   * java.sql.SQLXML
   * java.sql.Struct
 
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetCallableStatement.java 
b/src/main/java/nl/cwi/monetdb/jdbc/MonetCallableStatement.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetCallableStatement.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetCallableStatement.java
@@ -23,6 +23,7 @@ import java.sql.Ref;
 import java.sql.RowId;
 import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
+import java.sql.SQLType;       // new as of Java 1.8
 import java.sql.SQLXML;
 import java.sql.Time;
 import java.sql.Timestamp;
@@ -63,7 +64,7 @@ import java.util.Map;
  * because output parameters in stored procedures are not supported by MonetDB.
  *
  * @author Martin van Dinther
- * @version 1.0
+ * @version 1.1
  */
 
 public class MonetCallableStatement
@@ -631,5 +632,44 @@ public class MonetCallableStatement
                throw newSQLFeatureNotSupportedException("wasNull");
        }
 
+       //== Java 1.8 methods (JDBC 4.2)
+
+       @Override
+       public void setObject(String parameterName, Object x, SQLType 
targetSqlType, int scaleOrLength) throws SQLException {
+               // setObject(nameToIndex(parameterName), x, 
convertSQLType(targetSqlType), scaleOrLength);      // TODO implement 
convertSQLType(targetSqlType)
+               throw newSQLFeatureNotSupportedException("setObject");
+       }
+
+       @Override
+       public void setObject(String parameterName, Object x, SQLType 
targetSqlType) throws SQLException {
+               // setObject(nameToIndex(parameterName), x, 
convertSQLType(targetSqlType));     // TODO implement 
convertSQLType(targetSqlType)
+               throw newSQLFeatureNotSupportedException("setObject");
+       }
+
+       @Override
+       public void registerOutParameter(int parameterIndex, SQLType sqlType) 
throws SQLException {
+               throw 
newSQLFeatureNotSupportedException("registerOutParameter");
+       }
+       @Override
+       public void registerOutParameter(int parameterIndex, SQLType sqlType, 
int scale) throws SQLException {
+               throw 
newSQLFeatureNotSupportedException("registerOutParameter");
+       }
+       @Override
+       public void registerOutParameter(int parameterIndex, SQLType sqlType, 
String typeName) throws SQLException {
+               throw 
newSQLFeatureNotSupportedException("registerOutParameter");
+       }
+       @Override
+       public void registerOutParameter(String parameterName, SQLType sqlType) 
throws SQLException {
+               throw 
newSQLFeatureNotSupportedException("registerOutParameter");
+       }
+       @Override
+       public void registerOutParameter(String parameterName, SQLType sqlType, 
int scale) throws SQLException {
+               throw 
newSQLFeatureNotSupportedException("registerOutParameter");
+       }
+       @Override
+       public void registerOutParameter(String parameterName, SQLType sqlType, 
String typeName) throws SQLException {
+               throw 
newSQLFeatureNotSupportedException("registerOutParameter");
+       }
+
        // end methods interface CallableStatement
 }
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
@@ -2697,7 +2697,7 @@ public class MonetConnection
                /** The cache size (number of rows in a DataBlockResponse 
object) */
                private final int cachesize;
                /** The maximum number of results for this query */
-               private final int maxrows;
+               private final long maxrows;
                /** The ResultSet type to produce */
                private final int rstype;
                /** The ResultSet concurrency to produce */
@@ -2726,7 +2726,7 @@ public class MonetConnection
                 */
                ResponseList(
                        final int cachesize,
-                       final int maxrows,
+                       final long maxrows,
                        final int rstype,
                        final int rsconcur
                ) throws SQLException {
@@ -2858,7 +2858,7 @@ public class MonetConnection
                                         */
                                        int size = (cachesize == 0 ? 
DEF_FETCHSIZE : cachesize);
                                        if (maxrows > 0 && maxrows < size)
-                                               size = maxrows;
+                                               size = (int)maxrows;
                                        // don't do work if it's not needed
                                        if (lang == LANG_SQL && size != 
curReplySize && templ != commandTempl) {
                                                sendControlCommand("reply_size 
" + size);
@@ -2887,12 +2887,12 @@ public class MonetConnection
                                                                case 
StartOfHeaderParser.Q_TABLE:
                                                                case 
StartOfHeaderParser.Q_PREPARE: {
                                                                        final 
int id = sohp.getNextAsInt();
-                                                                       int 
tuplecount = sohp.getNextAsInt();
+                                                                       int 
tuplecount = sohp.getNextAsInt();   // TODO implement 
StartOfHeaderParser.getNextAsLong() and change tuplecount to long
                                                                        final 
int columncount = sohp.getNextAsInt();
                                                                        final 
int rowcount = sohp.getNextAsInt();
                                                                        // 
enforce the maxrows setting
                                                                        if 
(maxrows != 0 && tuplecount > maxrows)
-                                                                               
tuplecount = maxrows;
+                                                                               
tuplecount = (int)maxrows;
                                                                        res = 
new ResultSetResponse(id, tuplecount, columncount, rowcount, this, seqnr);
                                                                        // only 
add this resultset to the hashmap if it can possibly have an additional 
datablock
                                                                        if 
(rowcount < tuplecount) {
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java 
b/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
@@ -22,7 +22,7 @@ import java.sql.Types;
  *
  * @author Fabian Groffen
  * @author Martin van Dinther
- * @version 0.9
+ * @version 1.0
  */
 public class MonetDatabaseMetaData
        extends MonetWrapper
@@ -4023,12 +4023,12 @@ public class MonetDatabaseMetaData
                return true;
        }
 
-       //== 1.8 methods (JDBC 4.2)
+       //== Java 1.8 methods (JDBC 4.2)
 
        /**
         * Retrieves the maximum number of bytes this database allows for the 
logical size for a LOB.
         * The default implementation will return 0
-        * @return the maximum number of bytes
+        * @return the maximum number of bytes allowed; a result of zero means 
that there is no limit or the limit is not known
         */
        @Override
        public long getMaxLogicalLobSize() {
@@ -4038,7 +4038,7 @@ public class MonetDatabaseMetaData
        /**
         * Retrieves whether this database supports REF CURSOR.
         * The default implementation will return false
-        * @return true if so, false otherwise
+        * @return true if this database supports REF CURSOR; false otherwise
         */
        @Override
        public boolean supportsRefCursors() {
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
@@ -30,6 +30,7 @@ import java.sql.SQLDataException;
 import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
 import java.sql.SQLOutput;
+import java.sql.SQLType;       // new as of Java 1.8
 import java.sql.SQLXML;
 import java.sql.Struct;
 import java.sql.Time;
@@ -61,7 +62,7 @@ import java.util.Map;
  *
  * @author Fabian Groffen
  * @author Martin van Dinther
- * @version 0.5
+ * @version 0.6
  */
 public class MonetPreparedStatement
        extends MonetStatement
@@ -2613,8 +2614,46 @@ public class MonetPreparedStatement
                close();
        }
 
+       //== Java 1.8 methods (JDBC 4.2)
+
+       @Override
+       public void setObject(final int parameterIndex, final Object x, final 
SQLType targetSqlType, final int scaleOrLength) throws SQLException {
+               // setObject(parameterIndex, x, convertSQLType(targetSqlType), 
scaleOrLength);  // TODO implement convertSQLType(targetSqlType)
+               throw newSQLFeatureNotSupportedException("setObject");
+       }
+
+       @Override
+       public void setObject(final int parameterIndex, final Object x, final 
SQLType targetSqlType) throws SQLException {
+               // setObject(parameterIndex, x, convertSQLType(targetSqlType)); 
// TODO implement convertSQLType(targetSqlType)
+               throw newSQLFeatureNotSupportedException("setObject");
+       }
+
+       /**
+        * Executes the SQL statement in this PreparedStatement object, which 
must be
+        * an SQL Data Manipulation Language (DML) statement, such as INSERT, 
UPDATE or DELETE statement;
+        * or an SQL statement that returns nothing, such as a DDL statement.
+        *
+        * This method should be used when the returned row count may exceed 
Integer.MAX_VALUE.
+        * The default implementation will throw UnsupportedOperationException
+        *
+        * @return either (1) the row count for SQL Data Manipulation Language 
(DML) statements
+        *         or (2) 0 for SQL statements that return nothing
+        * @throws SQLException if a database access error occurs; this method 
is called on a closed PreparedStatement
+        *              or the SQL statement returns a ResultSet object
+        */
+       @Override
+       public long executeLargeUpdate() throws SQLException {
+               if (execute() != false)
+                       throw new SQLException("Query produced a result set", 
"M1M17");
+
+               return getLargeUpdateCount();
+       }
+
        //== end methods interface PreparedStatement
 
+
+       //== internal helper methods which do not belong to the JDBC interface
+
        /**
         * Sets the given index with the supplied value. If the given index is
         * out of bounds, and SQLException is thrown.  The given value should
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
@@ -29,6 +29,7 @@ import java.sql.SQLDataException;
 import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
 import java.sql.SQLInput;
+import java.sql.SQLType;       // new as of Java 1.8
 import java.sql.SQLWarning;
 import java.sql.SQLXML;
 import java.sql.Statement;
@@ -58,8 +59,9 @@ import java.util.TimeZone;
  * for FORWARD_ONLY result sets the memory usage will be likely lower for large
  * result sets.
  *
- * @author Fabian Groffen, Martin van Dinther
- * @version 0.8
+ * @author Fabian Groffen
+ * @author Martin van Dinther
+ * @version 0.9
  */
 public class MonetResultSet
        extends MonetWrapper
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to