0

I am using EnterpriseDB 9.2 advanced server (an Oracle compatible PostgreSQL fork) and I want to read data from a clob or text type data type column using getClob() method.

I'm getting error when trying:

org.postgresql.util.PSQLException: Bad value for type long :
adminuser@domainUser Logged In Sucessfully at org.postgresql.jdbc2.AbstractJdbc2ResultSet.toLong(AbstractJdbc2ResultSet.java:2‌​971) at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getLong(AbstractJdbc2ResultSet.java:‌​2163) at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getClob(AbstractJdbc2ResultSet.java:‌​436)

So is it possible to read data from above mentioned scenario using any technique in postgresql?

Daniel Vérité
  • 58,074
  • 15
  • 129
  • 156
Krishna
  • 795
  • 2
  • 7
  • 24
  • 1
    By "oracle compatible" - Do you mean EnterpriseDB Advanced Server? Please be specific about thwat *exactly* you are running. Show the *exact* error messsage with full stack trace. Show the code you're running. Details pleae. – Craig Ringer Apr 24 '14 at 09:51
  • ya i mean yes i'm using EnterpriseDB Advanced Server,org.postgresql.util.PSQLException: Bad value for type long : adminuser@domainUser Logged In Sucessfully at org.postgresql.jdbc2.AbstractJdbc2ResultSet.toLong(AbstractJdbc2ResultSet.java:2971) at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getLong(AbstractJdbc2ResultSet.java:2163) at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getClob(AbstractJdbc2ResultSet.java:436) – Krishna Apr 24 '14 at 10:18
  • Use `getString()` - that will work in Oracle and Postgres (provided you use an up-to-date driver for Oracle) –  Apr 24 '14 at 11:53
  • thank you, it's working means getString() is working for reading the clob or text data in postgresql 9.2, oracle and sql server also. – Krishna Apr 24 '14 at 12:22

1 Answers1

0

In a case of using Hibernate you can define the entity as shown below. The solution works well at least on PostgreSQL, H2 and HSQLDB (I didn't check other DBs):

@Column(columnDefinition = "CLOB")
String myClobField;
Ilya Lysenko
  • 1,772
  • 15
  • 24