# HG changeset patch # User Martin van Dinther <martin.van.dinther@monetdbsolutions.com> # Date 1502987785 -7200 # Node ID 1e49fc74dba49cfe5ee3e09dd3d6ffc05bad7ffc # Parent db5fa40cfa31ccaa095427db63ef5354979ff334 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. 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 <martin.van.dinther@monetdbsolutions.com> +- 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 <sjoerd@acm.org> - 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"); } /**