Changeset: 1e49fc74dba4 for monetdb-java
URL: https://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=1e49fc74dba4
Modified Files:
        ChangeLog
        release.txt
        src/main/java/nl/cwi/monetdb/jdbc/MonetClob.java
Branch: default
Log Message:

Implemented methods getCharacterStream() and getCharacterStream(long pos, long 
length) in class MonetClob.
Method getCharacterStream() is called by DBeaver to fetch the Clob value.
It used to throw a SQLFeatureNotSupportedException with message:
 "Method getCharacterStream() currently not supported"
This caused DBeaver to log the exception and show NULL as the value on screen, 
which is incorrect.
By implementing these methods it now works as expected for DBeaver and other 
generic SQL client tools using JDBC.


diffs (94 lines):

diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,15 @@
 # ChangeLog file for monetdb-java
 # This file is updated with Maddlog
 
+* Thu Aug 17 2017 Martin van Dinther <[email protected]>
+- In class MonetClob implemented methods getCharacterStream()
+  and getCharacterStream(long pos, long length).  Method
+  getCharacterStream() is called by DBeaver to fetch the Clob value.
+  It used to throw a SQLFeatureNotSupportedException with message:
+  "Method getCharacterStream() currently not supported" This caused
+  DBeaver to log the exception and show NULL as the value on screen,
+  which is incorrect.  This has been fixed.
+
 * Fri Jul 28 2017 Sjoerd Mullender <[email protected]>
 - Compiled and released new jars: monetdb-jdbc-2.26.jar and updated 
jdbcclient.jar
 
diff --git a/release.txt b/release.txt
--- a/release.txt
+++ b/release.txt
@@ -83,7 +83,6 @@ Currently implemented JDBC 4.1 interface
     A simple implementation using a StringBuilder to store the whole CLOB
     The next features/methods are NOT implemented:
     - getAsciiStream
-    - getCharacterStream
     - setAsciiStream
     - setCharacterStream
 
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetClob.java 
b/src/main/java/nl/cwi/monetdb/jdbc/MonetClob.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetClob.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetClob.java
@@ -11,6 +11,7 @@ package nl.cwi.monetdb.jdbc;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.Reader;
+import java.io.StringReader;
 import java.io.Writer;
 import java.sql.Clob;
 import java.sql.SQLException;
@@ -38,7 +39,7 @@ public class MonetClob implements Clob {
        /* internal utility method */
        private void checkBufIsNotNull() throws SQLException {
                if (buf == null)
-                       throw new SQLException("This Clob has been freed", 
"M1M20");
+                       throw new SQLException("This MonetClob has been freed", 
"M1M20");
        }
 
        //== begin interface Clob
@@ -68,7 +69,7 @@ public class MonetClob implements Clob {
         */
        @Override
        public InputStream getAsciiStream() throws SQLException {
-               throw new SQLFeatureNotSupportedException("Method 
getAsciiStream() currently not supported", "0A000");
+               throw new SQLFeatureNotSupportedException("Method 
getAsciiStream() not supported", "0A000");
        }
 
        /**
@@ -81,7 +82,8 @@ public class MonetClob implements Clob {
         */
        @Override
        public Reader getCharacterStream() throws SQLException {
-               throw new SQLFeatureNotSupportedException("Method 
getCharacterStream() currently not supported", "0A000");
+               checkBufIsNotNull();
+               return new StringReader(buf.toString());
        }
 
        /**
@@ -100,7 +102,8 @@ public class MonetClob implements Clob {
         */
        @Override
        public Reader getCharacterStream(long pos, long length) throws 
SQLException {
-               throw new SQLFeatureNotSupportedException("Method 
getCharacterStream(long, long) currently not supported", "0A000");
+               checkBufIsNotNull();
+               return new StringReader(getSubString(pos, (int)length));
        }
 
        /**
@@ -179,12 +182,12 @@ public class MonetClob implements Clob {
 
        @Override
        public OutputStream setAsciiStream(long pos) throws SQLException {
-               throw new SQLException("Method setAsciiStream(long pos) 
currently not supported", "0A000");
+               throw new SQLFeatureNotSupportedException("Method 
setAsciiStream(long pos) not supported", "0A000");
        }
 
        @Override
        public Writer setCharacterStream(long pos) throws SQLException {
-               throw new SQLException("Method setCharacterStream(long pos) 
currently not supported", "0A000");
+               throw new SQLFeatureNotSupportedException("Method 
setCharacterStream(long pos) not supported", "0A000");
        }
 
        /**
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to