Changeset: 49596fdde953 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=49596fdde953
Modified Files:
        configure.ag
        java/ChangeLog
        java/Makefile.ag
        java/build.properties
        java/release.txt
        java/src/nl/cwi/monetdb/jdbc/MonetBlob.java
        java/src/nl/cwi/monetdb/jdbc/MonetClob.java
        java/src/nl/cwi/monetdb/jdbc/MonetConnection.java
        java/src/nl/cwi/monetdb/jdbc/MonetDataSource.java
        java/src/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
        java/src/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
        java/src/nl/cwi/monetdb/jdbc/MonetResultSet.java
        java/src/nl/cwi/monetdb/jdbc/MonetStatement.java
        java/src/nl/cwi/monetdb/jdbc/MonetWrapper.java
Branch: default
Log Message:

jdbc: implement changes necessary for JDBC4

JDBC4 was introduced with Java 6.  Adding support for this was long
overdue, since Java 5 has reached its EOL for a while now.  We decided
not to add any backwards compatible Java 5 code path, since Java 5
should be close to extinct.  See bug #2802.


diffs (truncated from 2097 to 300 lines):

diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -1619,14 +1619,14 @@ no-*)
        fi
        ;;
 *)
-       if test MONETDB_VERSION_TO_NUMBER(echo $JAVA_VERSION) = 
MONETDB_VERSION_TO_NUMBER(echo "1.5") ; then
+       if test MONETDB_VERSION_TO_NUMBER(echo $JAVA_VERSION) -ge 
MONETDB_VERSION_TO_NUMBER(echo "1.6") ; then
                have_java_jdbc=yes
        else
                if test "x$enable_jdbc" = xyes; then
-                       AC_MSG_ERROR([MonetDB JDBC requires ant and Java 1.5])
+                       AC_MSG_ERROR([MonetDB JDBC requires ant and Java 6 or 
higher])
                else
                        enable_jdbc=no
-                       disable_jdbc="(MonetDB JDBC currently requires Java 1.5 
to build)"
+                       disable_jdbc="(MonetDB JDBC currently requires Java 6 
or higher to build)"
                fi
        fi
        ;;
diff --git a/java/ChangeLog b/java/ChangeLog
--- a/java/ChangeLog
+++ b/java/ChangeLog
@@ -1,6 +1,11 @@
 # ChangeLog file for java
 # This file is updated with Maddlog
 
+* Fri Oct 14 2011 Fabian Groffen <[email protected]>
+- Bump JDBC version to 2.0 (Liberica).  JDBC now implements JDBC4 which
+  makes it possible to be built with Java 6 and up.  Java 5 and before
+  are no longer supported, and can use the 1.x releases of the driver.
+
 * Thu Sep  1 2011 Fabian Groffen <[email protected]>
 - INTERVAL columns are now treated as decimals, since they can have
   sub-second precision.
diff --git a/java/Makefile.ag b/java/Makefile.ag
--- a/java/Makefile.ag
+++ b/java/Makefile.ag
@@ -27,7 +27,7 @@ JAVA_HOME = @JAVA_HOME@
 ant_distjdbc = {
        COND = HAVE_JAVAJDBC
        DIR = datadir/monetdb/lib
-       FILES = monetdb-1.6-mcl.jar monetdb-1.23-jdbc.jar jdbcclient.jar
+       FILES = monetdb-1.6-mcl.jar monetdb-2.0-jdbc.jar jdbcclient.jar
 }
 
 ant_distmerocontrol = {
diff --git a/java/build.properties b/java/build.properties
--- a/java/build.properties
+++ b/java/build.properties
@@ -17,11 +17,11 @@ MCL_MINOR=6
 ##
 
 # major release number
-JDBC_MAJOR=1
+JDBC_MAJOR=2
 # minor release number
-JDBC_MINOR=23
+JDBC_MINOR=0
 # an additional identifying string
-JDBC_VER_SUFFIX=Magnistipula
+JDBC_VER_SUFFIX=Liberica
 # the default port to connect on, if no port given when using SQL
 JDBC_DEF_PORT=50000
 
@@ -35,5 +35,4 @@ enable_debug=true
 # should we optimize the build, preferably not for debugging
 enable_optimize=false
 # what JVM do we want to be compatible with?
-# 1.5 is the current J2EE, nl.cwi.monetdb.merovingian code uses 1.5 features
-javac_version=1.5
+javac_version=1.6
diff --git a/java/release.txt b/java/release.txt
--- a/java/release.txt
+++ b/java/release.txt
@@ -1,8 +1,8 @@
 RELEASE NOTES
-MonetDB JDBC driver version 1.23 (Magnistipula/MCL-1.6)
+MonetDB JDBC driver version 2.0 (Liberica/MCL-1.6)
 Fabian Groffen <[email protected]>
 
-Release date: 2011-09-01
+Release date: 2011-10-14
 
 
 This JDBC driver is designed for use with MonetDB, a main-memory
@@ -12,8 +12,8 @@ Within the current implementation not al
 interface are available.  It is believed, however, that this
 implementation is rich enough to be suitable for a majority of
 application settings.
-Most notably, JDBC4 is not implemented at the moment.  This disallows
-Java 1.6 and up to compile the driver from source.
+Note that this driver is JDBC4 compatible, and hence cannot be compiled
+with Java 1.5 and earlier.
 
 Below a list of supported features can be found.  Please read this list
 if you intend to use this driver.  If you feel some features are
diff --git a/java/src/nl/cwi/monetdb/jdbc/MonetBlob.java 
b/java/src/nl/cwi/monetdb/jdbc/MonetBlob.java
--- a/java/src/nl/cwi/monetdb/jdbc/MonetBlob.java
+++ b/java/src/nl/cwi/monetdb/jdbc/MonetBlob.java
@@ -44,11 +44,71 @@ public class MonetBlob implements Blob {
 
        //== begin interface Blob
        
+       /**
+        * This method frees the Blob object and releases the resources that
+        * it holds. The object is invalid once the free method is called.
+        * <br /><br />
+        * After free has been called, any attempt to invoke a method other
+        * than free will result in a SQLException being thrown. If free is
+        * called multiple times, the subsequent calls to free are treated
+        * as a no-op.
+        *
+        * @throws SQLException if an error occurs releasing the Blob's
+        *         resources
+        * @throws SQLFeatureNotSupportedException - if the JDBC driver does
+        *         not support this method
+        */
+       public void free() throws SQLException {
+               buf = null;
+       }
+       
+       /**
+        * Retrieves the BLOB value designated by this Blob instance as a
+        * stream.
+        *
+        * @return a stream containing the BLOB data
+        * @throws SQLException if there is an error accessing the BLOB value
+        * @throws SQLFeatureNotSupportedException if the JDBC driver does
+        *         not support this method
+        */
        public InputStream getBinaryStream() throws SQLException {
+               if (buf == null)
+                       throw new SQLException("This Blob object has been 
freed");
                return(new ByteArrayInputStream(buf));
        }
 
        /**
+        * Returns an InputStream object that contains a partial Blob value,
+        * starting with the byte specified by pos, which is length bytes in
+        * length.
+        *
+        * @param pos the offset to the first byte of the partial value to
+        *        be retrieved. The first byte in the Blob is at position 1
+        * @param length the length in bytes of the partial value to be
+        *        retrieved
+        * @return InputStream through which the partial Blob value can be
+        *         read.
+        * @throws SQLException if pos is less than 1 or if pos is
+        *         greater than the number of bytes in the Blob or if pos +
+        *         length is greater than the number of bytes in the Blob 
+        * @throws SQLFeatureNotSupportedException if the JDBC driver does
+        *         not support this method
+        */
+       public InputStream getBinaryStream(long pos, long length)
+               throws SQLException
+       {
+               if (buf == null)
+                       throw new SQLException("This Blob object has been 
freed");
+               if (pos < 1)
+                       throw new SQLException("pos is less than 1");
+               if (pos - 1 > buf.length)
+                       throw new SQLException("pos is greater than the number 
of bytes in the Blob");
+               if (pos - 1 + length > buf.length)
+                       throw new SQLException("pos + length is greater than 
the number of bytes in the Blob");
+               return(new ByteArrayInputStream(buf, (int)(pos - 1), 
(int)length));
+       }
+
+       /**
         * Retrieves all or part of the BLOB value that this Blob object
         * represents, as an array of bytes.  This byte array contains up to
         * length consecutive bytes starting at position pos.
@@ -63,6 +123,8 @@ public class MonetBlob implements Blob {
         *         BLOB value
         */
        public byte[] getBytes(long pos, int length) throws SQLException {
+               if (buf == null)
+                       throw new SQLException("This Blob object has been 
freed");
                try {
                        byte[] r = new byte[length];
                        for (int i = 0; i < length; i++)
@@ -82,6 +144,8 @@ public class MonetBlob implements Blob {
         *         of the BLOB value
         */
        public long length() throws SQLException {
+               if (buf == null)
+                       throw new SQLException("This Blob object has been 
freed");
                return((long)buf.length);
        }
 
@@ -115,6 +179,8 @@ public class MonetBlob implements Blob {
         *         BLOB value
         */
        public long position(byte[] pattern, long start) throws SQLException {
+               if (buf == null)
+                       throw new SQLException("This Blob object has been 
freed");
                try {
                        for (int i = (int)(start - 1); i < buf.length - 
pattern.length; i++) {
                                int j;
@@ -131,8 +197,30 @@ public class MonetBlob implements Blob {
                return(-1);
        }
 
+       /**
+        * Retrieves a stream that can be used to write to the BLOB value
+        * that this Blob object represents. The stream begins at position
+        * pos. The bytes written to the stream will overwrite the existing
+        * bytes in the Blob object starting at the position pos. If the end
+        * of the Blob value is reached while writing to the stream, then
+        * the length of the Blob value will be increased to accomodate the
+        * extra bytes.
+        *
+        * @param pos the position in the BLOB value at which to start
+        *            writing; the first position is 1
+        * @return a java.io.OutputStream object to which data can be
+        *         written
+        * @throws SQLException if there is an error accessing the BLOB
+        *         value or if pos is less than 1
+        * @throws SQLFeatureNotSupportedException if the JDBC driver does
+        *         not support this method
+        */
        public OutputStream setBinaryStream(long pos) throws SQLException {
-               throw new SQLException("Operation setBinaryStream(long pos) 
currently not supported");
+               if (buf == null)
+                       throw new SQLException("This Blob object has been 
freed");
+               if (pos < 1)
+                       throw new SQLException("pos is less than 1");
+               throw new SQLFeatureNotSupportedException("Operation 
setBinaryStream(long pos) currently not supported");
        }
 
        /**
@@ -173,6 +261,8 @@ public class MonetBlob implements Blob {
        public int setBytes(long pos, byte[] bytes, int offset, int len)
                throws SQLException
        {
+               if (buf == null)
+                       throw new SQLException("This Blob object has been 
freed");
                try {
                        /* transactions? what are you talking about? */
                        for (int i = (int)pos; i < len; i++)
@@ -192,7 +282,9 @@ public class MonetBlob implements Blob {
         * @throws SQLException if there is an error accessing the
         *         BLOB value
         */
-       public void truncate(long len) {
+       public void truncate(long len) throws SQLException {
+               if (buf == null)
+                       throw new SQLException("This Blob object has been 
freed");
                if (buf.length > len) {
                        byte[] newbuf = new byte[(int)len];
                        for (int i = 0; i < len; i++)
diff --git a/java/src/nl/cwi/monetdb/jdbc/MonetClob.java 
b/java/src/nl/cwi/monetdb/jdbc/MonetClob.java
--- a/java/src/nl/cwi/monetdb/jdbc/MonetClob.java
+++ b/java/src/nl/cwi/monetdb/jdbc/MonetClob.java
@@ -42,12 +42,60 @@ public class MonetClob implements Clob {
 
        //== begin interface Clob
        
-       public InputStream getAsciiStream() throws SQLException {
-               throw new SQLException("Operation getAsciiStream() currently 
not supported");
+       /**
+        * This method frees the Clob object and releases the resources the
+        * resources that it holds. The object is invalid once the free
+        * method is called.
+        *
+        * After free has been called, any attempt to invoke a method other
+        * than free will result in a SQLException being thrown. If free is
+        * called multiple times, the subsequent calls to free are treated
+        * as a no-op.
+        */
+       public void free() {
+               buf = null;
        }
 
+       /**
+        * Retrieves the CLOB value designated by this Clob object as an
+        * ascii stream.
+        *
+        * @return a java.io.InputStream object containing the CLOB data
+        * @throws SQLFeatureNotSupportedException this JDBC driver does
+        *         not support this method
+        */
+       public InputStream getAsciiStream() throws SQLException {
+               throw new SQLFeatureNotSupportedException("Operation 
getAsciiStream() currently not supported");
+       }
+
+       /**
+        * Retrieves the CLOB value designated by this Clob object as a
+        * java.io.Reader object (or as a stream of characters).
+        *
+        * @return a java.io.Reader object containing the CLOB data
+        * @throws SQLFeatureNotSupportedException this JDBC driver does
+        *         not support this method
+        */
        public Reader getCharacterStream() throws SQLException {
-               throw new SQLException("Operation getCharacterStream() 
currently not supported");
+               throw new SQLFeatureNotSupportedException("Operation 
getCharacterStream() currently not supported");
+       }
+
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to