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 <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
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