使用postgreSQL的CLOB字符串

Ben*_*cha 8 sql postgresql clob

我正在尝试从postgreSQL DB中读取一个clob,更改它并将其写回.

我能够使用以下代码成功读取clob:

PreparedStatement statement = connection.prepareStatement("SELECT clob_column from data where id = 1");
ResultSet executeQuery = statement.executeQuery();
executeQuery.next()
Clob fetchedClob = executeQuery.getClob("clob_column");
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试使用以下新数据创建新clob时:

Clob newClob = connection.createClob();
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

java.lang.AbstractMethodError: com.mchange.v2.c3p0.impl.NewProxyConnection.createClob()Ljava/sql/Clob;  
Run Code Online (Sandbox Code Playgroud)

此外,如果我尝试只是编辑获取的clob,使用:

fetchedClob.setString(0, "new string");
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

Method org.postgresql.jdbc4.Jdbc4Clob.setString(long,str) is not yet implemented.
Run Code Online (Sandbox Code Playgroud)

任何的想法?

更新:这是表定义

CREATE TABLE数据(id bigint NOT NULL,clob_column text,);

谢谢

a_h*_*ame 5

无需使用getClob().

ResultSet.getString()并且setString()text列上工作得很好(PostgreSQL没有clob数据类型所以我假设你正在使用text)