Blob and Clob not implement in JDBC v 2.10?

Hello, I am not able to get Blob and Clob to work in JDBC v 2.10? I get a SQLFeatureNotSupportedException? Is this the correct behavior? Thanks, Phat

Hello Phat, On 04/09/2014 10:11 PM, Phat Loc wrote:
I am not able to get Blob and Clob to work in JDBC v 2.10? I get a SQLFeatureNotSupportedException? Is this the correct behavior?
sql>create table clobtest (a clob); operation successful (104.179ms) sql>insert into clobtest values ('adsf'); 1 affected row (9.055ms) sql>select * from clobtest; +------+ | a | +======+ | adsf | +------+ 1 tuple (0.766ms) If I connect to that using JDBC with the following program package test; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class TestCall { public static void main(String[] args) { try { Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); Connection con = DriverManager .getConnection("jdbc:monetdb://localhost:50000/acs", "monetdb", "monetdb"); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select a from clobtest"); if (rs.next()) System.out.println("JDBC Result: "+rs.getClob(1)); } catch (Exception e) { e.printStackTrace(); } } } I get JDBC Result: adsf From what I can see, this should work. Perhaps you can share more details on what you are doing. Also, if you append ?debug=true to the JDBC URL (e.g. jdbc:monetdb://localhost:50000/acs?debug=true in the above example), the JDBC driver produces a log file that help us tell what is going on. Best, Hannes

Does not work for prepared statements. See below.
package jdbcForMonetdb;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import java.io.StringReader;
import java.sql.Statement;
public class TestCall {
public static void main(String[] args) {
try {
Class.forName("nl.cwi.monetdb.jdbc.MonetDriver");
Connection con = DriverManager
.getConnection("jdbc:monetdb://localhost:50000/acs",
"monetdb", "monetdb");
PreparedStatement stmt = con.prepareStatement("insert into
clobtest values(?);");
stmt.setClob(1, new StringReader("ABCDEDFG"));
stmt.execute();
con.close();
//ResultSet rs = stmt.executeQuery("select a from clobtest");
//if (rs.next()) System.out.println("JDBC Result:
"+rs.getClob(1));
} catch (Exception e) {
e.printStackTrace();
}
}
}
-------------------------
/usr/lib/jvm/java-7-oracle/bin/java
-agentlib:jdwp=transport=dt_socket,address=127.0.0.1:56499,suspend=y,server=n
-Dfile.encoding=UTF-8 -classpath
/usr/lib/jvm/java-7-oracle/jre/lib/deploy.jar:/usr/lib/jvm/java-7-oracle/jre/lib/rt.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jfxrt.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jce.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jsse.jar:/usr/lib/jvm/java-7-oracle/jre/lib/plugin.jar:/usr/lib/jvm/java-7-oracle/jre/lib/resources.jar:/usr/lib/jvm/java-7-oracle/jre/lib/javaws.jar:/usr/lib/jvm/java-7-oracle/jre/lib/management-agent.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jfr.jar:/usr/lib/jvm/java-7-oracle/jre/lib/charsets.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/zipfs.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunec.jar:/home/ploc/IdeaProjects/jdbcForMonetdb/out/production/jdbcForMonetdb:/home/ploc/Downloads/monetdb-jdbc-2.10.jar:/home/ploc/Downloads/idea-IC-135.480/lib/idea_rt.jar
jdbcForMonetdb.TestCall
Connected to the target VM, address: '127.0.0.1:56499', transport: 'socket'
java.sql.SQLFeatureNotSupportedException: setClob(int, Reader) not supported
at
nl.cwi.monetdb.jdbc.MonetPreparedStatement.setClob(MonetPreparedStatement.java:1280)
at jdbcForMonetdb.TestCall.main(TestCall.java:20)
On Thu, Apr 10, 2014 at 3:32 AM, Hannes Mühleisen
Hello Phat,
On 04/09/2014 10:11 PM, Phat Loc wrote:
I am not able to get Blob and Clob to work in JDBC v 2.10? I get a SQLFeatureNotSupportedException? Is this the correct behavior?
sql>create table clobtest (a clob); operation successful (104.179ms) sql>insert into clobtest values ('adsf'); 1 affected row (9.055ms) sql>select * from clobtest; +------+ | a | +======+ | adsf | +------+ 1 tuple (0.766ms)
If I connect to that using JDBC with the following program
package test;
import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement;
public class TestCall { public static void main(String[] args) { try { Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); Connection con = DriverManager .getConnection("jdbc:monetdb:/ /localhost:50000/acs", "monetdb", "monetdb"); Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select a from clobtest"); if (rs.next()) System.out.println("JDBC Result: "+rs.getClob(1)); } catch (Exception e) { e.printStackTrace(); } } }
I get
JDBC Result: adsf
From what I can see, this should work. Perhaps you can share more details on what you are doing. Also, if you append ?debug=true to the JDBC URL (e.g. jdbc:monetdb://localhost:50000/acs?debug=true in the above example), the JDBC driver produces a log file that help us tell what is going on.
Best,
Hannes
_______________________________________________ users-list mailing list users-list@monetdb.org https://www.monetdb.org/mailman/listinfo/users-list

Hi Phat, thanks for the clarification. From looking at the code, the setClob method is not supported if no length of the content in the reader is given. So, to make it work, you can explicitly set the length of the content in the reader. stmt.setClob(1, new StringReader("ABCDEDFG"),8); From looking at the Reader interface [1], it is possible to read until the end of the content is reached. I have filed this as Bug 3470 [2]. Best, Hannes [1] http://docs.oracle.com/javase/7/docs/api/java/io/Reader.html [2] http://bugs.monetdb.org/show_bug.cgi?id=3470 On 04/10/2014 06:55 PM, Phat Loc wrote:
Does not work for prepared statements. See below.
package jdbcForMonetdb;
import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.PreparedStatement; import java.io.StringReader; import java.sql.Statement;
public class TestCall { public static void main(String[] args) { try { Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); Connection con = DriverManager .getConnection("jdbc:monetdb://localhost:50000/acs", "monetdb", "monetdb");
PreparedStatement stmt = con.prepareStatement("insert into clobtest values(?);");
stmt.setClob(1, new StringReader("ABCDEDFG")); stmt.execute(); con.close(); //ResultSet rs = stmt.executeQuery("select a from clobtest"); //if (rs.next()) System.out.println("JDBC Result: "+rs.getClob(1)); } catch (Exception e) { e.printStackTrace(); } } }
------------------------- /usr/lib/jvm/java-7-oracle/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:56499 http://127.0.0.1:56499,suspend=y,server=n -Dfile.encoding=UTF-8 -classpath /usr/lib/jvm/java-7-oracle/jre/lib/deploy.jar:/usr/lib/jvm/java-7-oracle/jre/lib/rt.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jfxrt.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jce.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jsse.jar:/usr/lib/jvm/java-7-oracle/jre/lib/plugin.jar:/usr/lib/jvm/java-7-oracle/jre/lib/resources.jar:/usr/lib/jvm/java-7-oracle/jre/lib/javaws.jar:/usr/lib/jvm/java-7-oracle/jre/lib/management-agent.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jfr.jar:/usr/lib/jvm/java-7-oracle/jre/lib/charsets.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/zipfs.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunec.jar:/home/ploc/IdeaProjects/jdbcForMonetdb/out/production/jdbcForMonetdb:/home/ploc/Downloads/monetdb-jdbc-2.10.jar:/home/ploc/Downloads/idea-IC-135.480/lib/idea_rt.jar jdbcForMonetdb.TestCall Connected to the target VM, address: '127.0.0.1:56499 http://127.0.0.1:56499', transport: 'socket' java.sql.SQLFeatureNotSupportedException: setClob(int, Reader) not supported at nl.cwi.monetdb.jdbc.MonetPreparedStatement.setClob(MonetPreparedStatement.java:1280) at jdbcForMonetdb.TestCall.main(TestCall.java:20)
On Thu, Apr 10, 2014 at 3:32 AM, Hannes Mühleisen
mailto:Hannes.Muehleisen@cwi.nl> wrote: Hello Phat,
On 04/09/2014 10:11 PM, Phat Loc wrote:
I am not able to get Blob and Clob to work in JDBC v 2.10? I get a SQLFeatureNotSupportedExceptio__n? Is this the correct behavior?
sql>create table clobtest (a clob); operation successful (104.179ms) sql>insert into clobtest values ('adsf'); 1 affected row (9.055ms) sql>select * from clobtest; +------+ | a | +======+ | adsf | +------+ 1 tuple (0.766ms)
If I connect to that using JDBC with the following program
package test;
import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement;
public class TestCall { public static void main(String[] args) { try {
Class.forName("nl.cwi.monetdb.__jdbc.MonetDriver"); Connection con = DriverManager
.getConnection("jdbc:monetdb:/__/localhost:50000/acs", "monetdb", "monetdb"); Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select a from clobtest"); if (rs.next()) System.out.println("JDBC Result: "+rs.getClob(1)); } catch (Exception e) { e.printStackTrace(); } } }
I get
JDBC Result: adsf
From what I can see, this should work. Perhaps you can share more details on what you are doing. Also, if you append ?debug=true to the JDBC URL (e.g. jdbc:monetdb://localhost:__50000/acs?debug=true in the above example), the JDBC driver produces a log file that help us tell what is going on.
Best,
Hannes
_______________________________________________ users-list mailing list users-list@monetdb.org mailto:users-list@monetdb.org https://www.monetdb.org/mailman/listinfo/users-list
_______________________________________________ users-list mailing list users-list@monetdb.org https://www.monetdb.org/mailman/listinfo/users-list

Hello Phat (and list), while looking at this, I found a bug in the setClob() method that includes the length parameter. So this does currently not work at all. See the bug [1] for details and updates. Best, Hannes [1] http://bugs.monetdb.org/show_bug.cgi?id=3470 On 04/11/2014 10:32 AM, Hannes Mühleisen wrote:
Hi Phat,
thanks for the clarification. From looking at the code, the setClob method is not supported if no length of the content in the reader is given. So, to make it work, you can explicitly set the length of the content in the reader.
stmt.setClob(1, new StringReader("ABCDEDFG"),8);
From looking at the Reader interface [1], it is possible to read until the end of the content is reached. I have filed this as Bug 3470 [2].
Best,
Hannes
[1] http://docs.oracle.com/javase/7/docs/api/java/io/Reader.html [2] http://bugs.monetdb.org/show_bug.cgi?id=3470
On 04/10/2014 06:55 PM, Phat Loc wrote:
Does not work for prepared statements. See below.
package jdbcForMonetdb;
import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.PreparedStatement; import java.io.StringReader; import java.sql.Statement;
public class TestCall { public static void main(String[] args) { try { Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); Connection con = DriverManager .getConnection("jdbc:monetdb://localhost:50000/acs", "monetdb", "monetdb");
PreparedStatement stmt = con.prepareStatement("insert into clobtest values(?);");
stmt.setClob(1, new StringReader("ABCDEDFG")); stmt.execute(); con.close(); //ResultSet rs = stmt.executeQuery("select a from clobtest"); //if (rs.next()) System.out.println("JDBC Result: "+rs.getClob(1)); } catch (Exception e) { e.printStackTrace(); } } }
------------------------- /usr/lib/jvm/java-7-oracle/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:56499 http://127.0.0.1:56499,suspend=y,server=n -Dfile.encoding=UTF-8 -classpath /usr/lib/jvm/java-7-oracle/jre/lib/deploy.jar:/usr/lib/jvm/java-7-oracle/jre/lib/rt.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jfxrt.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jce.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jsse.jar:/usr/lib/jvm/java-7-oracle/jre/lib/plugin.jar:/usr/lib/jvm/java-7-oracle/jre/lib/resources.jar:/usr/lib/jvm/java-7-oracle/jre/lib/javaws.jar:/usr/lib/jvm/java-7-oracle/jre/lib/management-agent.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jfr.jar:/usr/lib/jvm/java-7-oracle/jre/lib/charsets.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/zipfs.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunec.jar:/home/ploc/IdeaProjects/jdbcForMonetdb/out/production/jdbcForMonetdb:/home/ploc/Downloads/monetdb-jdbc-2.10.jar:/home/ploc/Downloads/idea-IC-135.480/lib/idea_rt.jar
jdbcForMonetdb.TestCall Connected to the target VM, address: '127.0.0.1:56499 http://127.0.0.1:56499', transport: 'socket' java.sql.SQLFeatureNotSupportedException: setClob(int, Reader) not supported at nl.cwi.monetdb.jdbc.MonetPreparedStatement.setClob(MonetPreparedStatement.java:1280)
at jdbcForMonetdb.TestCall.main(TestCall.java:20)
On Thu, Apr 10, 2014 at 3:32 AM, Hannes Mühleisen
mailto:Hannes.Muehleisen@cwi.nl> wrote: Hello Phat,
On 04/09/2014 10:11 PM, Phat Loc wrote:
I am not able to get Blob and Clob to work in JDBC v 2.10? I get a SQLFeatureNotSupportedExceptio__n? Is this the correct behavior?
sql>create table clobtest (a clob); operation successful (104.179ms) sql>insert into clobtest values ('adsf'); 1 affected row (9.055ms) sql>select * from clobtest; +------+ | a | +======+ | adsf | +------+ 1 tuple (0.766ms)
If I connect to that using JDBC with the following program
package test;
import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement;
public class TestCall { public static void main(String[] args) { try {
Class.forName("nl.cwi.monetdb.__jdbc.MonetDriver"); Connection con = DriverManager
.getConnection("jdbc:monetdb:/__/localhost:50000/acs", "monetdb", "monetdb"); Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select a from clobtest"); if (rs.next()) System.out.println("JDBC Result: "+rs.getClob(1)); } catch (Exception e) { e.printStackTrace(); } } }
I get
JDBC Result: adsf
From what I can see, this should work. Perhaps you can share more details on what you are doing. Also, if you append ?debug=true to the JDBC URL (e.g. jdbc:monetdb://localhost:__50000/acs?debug=true in the above example), the JDBC driver produces a log file that help us tell what is going on.
Best,
Hannes

Thank you!
On Friday, April 11, 2014, Hannes Mühleisen
Hello Phat (and list),
while looking at this, I found a bug in the setClob() method that includes the length parameter. So this does currently not work at all. See the bug [1] for details and updates.
Best,
Hannes
[1] http://bugs.monetdb.org/show_bug.cgi?id=3470
On 04/11/2014 10:32 AM, Hannes Mühleisen wrote:
Hi Phat,
thanks for the clarification. From looking at the code, the setClob method is not supported if no length of the content in the reader is given. So, to make it work, you can explicitly set the length of the content in the reader.
stmt.setClob(1, new StringReader("ABCDEDFG"),8);
From looking at the Reader interface [1], it is possible to read until the end of the content is reached. I have filed this as Bug 3470 [2].
Best,
Hannes
[1] http://docs.oracle.com/javase/7/docs/api/java/io/Reader.html [2] http://bugs.monetdb.org/show_bug.cgi?id=3470
On 04/10/2014 06:55 PM, Phat Loc wrote:
Does not work for prepared statements. See below.
package jdbcForMonetdb;
import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.PreparedStatement; import java.io.StringReader; import java.sql.Statement;
public class TestCall { public static void main(String[] args) { try { Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); Connection con = DriverManager .getConnection("jdbc:monetdb://localhost:50000/acs", "monetdb", "monetdb");
PreparedStatement stmt = con.prepareStatement("insert into clobtest values(?);");
stmt.setClob(1, new StringReader("ABCDEDFG")); stmt.execute(); con.close(); //ResultSet rs = stmt.executeQuery("select a from clobtest"); //if (rs.next()) System.out.println("JDBC Result: "+rs.getClob(1)); } catch (Exception e) { e.printStackTrace(); } } }
------------------------- /usr/lib/jvm/java-7-oracle/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:56499 http://127.0.0.1:56499,suspend=y,server=n -Dfile.encoding=UTF-8 -classpath /usr/lib/jvm/java-7-oracle/jre/lib/deploy.jar:/usr/lib/ jvm/java-7-oracle/jre/lib/rt.jar:/usr/lib/jvm/java-7- oracle/jre/lib/jfxrt.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ jce.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jsse.jar:/usr/ lib/jvm/java-7-oracle/jre/lib/plugin.jar:/usr/lib/jvm/java- 7-oracle/jre/lib/resources.jar:/usr/lib/jvm/java-7- oracle/jre/lib/javaws.jar:/usr/lib/jvm/java-7-oracle/jre/ lib/management-agent.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ jfr.jar:/usr/lib/jvm/java-7-oracle/jre/lib/charsets.jar:/ usr/lib/jvm/java-7-oracle/jre/lib/ext/dnsns.jar:/usr/lib/ jvm/java-7-oracle/jre/lib/ext/sunjce_provider.jar:/usr/lib/ jvm/java-7-oracle/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/ java-7-oracle/jre/lib/ext/zipfs.jar:/usr/lib/jvm/java-7- oracle/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-7- oracle/jre/lib/ext/sunec.jar:/home/ploc/IdeaProjects/ jdbcForMonetdb/out/production/jdbcForMonetdb:/home/ploc/ Downloads/monetdb-jdbc-2.10.jar:/home/ploc/Downloads/idea- IC-135.480/lib/idea_rt.jar
jdbcForMonetdb.TestCall Connected to the target VM, address: '127.0.0.1:56499 http://127.0.0.1:56499', transport: 'socket' java.sql.SQLFeatureNotSupportedException: setClob(int, Reader) not supported at nl.cwi.monetdb.jdbc.MonetPreparedStatement.setClob( MonetPreparedStatement.java:1280)
at jdbcForMonetdb.TestCall.main(TestCall.java:20)
On Thu, Apr 10, 2014 at 3:32 AM, Hannes Mühleisen
mailto:Hannes.Muehleisen@cwi.nl> wrote: Hello Phat,
On 04/09/2014 10:11 PM, Phat Loc wrote:
I am not able to get Blob and Clob to work in JDBC v 2.10? I get a<
participants (2)
-
Hannes Mühleisen
-
Phat Loc