String for CLOB with postgreSQL

I am trying to read clob from postgreSQL DB, modify it and write it back.

I was able to successfully read clob using the following code:

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

But when I try to create a new clob with new data using:

 Clob newClob = connection.createClob(); 

I get the following error:

 java.lang.AbstractMethodError: com.mchange.v2.c3p0.impl.NewProxyConnection.createClob()Ljava/sql/Clob; 

Also, if I try to simply edit the selected clob using:

 fetchedClob.setString(0, "new string"); 

I get the following error:

 Method org.postgresql.jdbc4.Jdbc4Clob.setString(long,str) is not yet implemented. 

Any idea?

Update: here is the table definition

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

thanks

+8
sql postgresql clob
source share
1 answer

No need to use getClob() .

ResultSet.getString() and setString() work fine in text columns (PostgreSQL does not have a clob data clob , so I assume you are using text )

+5
source share

All Articles