Hi,
I've switched my empire-db (2.2.0) project from Oracle to Postgresql (version
8.4) and encountered two problems with CLOB columns.
First, trying to read the CLOB value from the result set using
DBReader.getValue() fails with the following error:
org.postgresql.util.PSQLException: Bad value for type long : some string value
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.toLong(AbstractJdbc2ResultSet.java:2796)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.getLong(AbstractJdbc2ResultSet.java:2019)
at org.postgresql.jdbc4.Jdbc4ResultSet.getClob(Jdbc4ResultSet.java:43)
at
org.apache.empire.db.DBDatabaseDriver.getResultValue(DBDatabaseDriver.java:490)
at org.apache.empire.db.DBReader.getValue(DBReader.java:374)
The problem is that DbReader eventually calls JDBC method getClob() which IMHO
is not implemented correctly in the postgresql driver. It is recommended to use
getString() method on the CLOBs in Postgresql instead. But calling
DBReader.getString() does not help either, because it ends up calling
getValue().toString(), with the same result as above. The same situation holds
for BLOBs as well. Any hints or workarounds, please?
The second problem is with the DDL generator, which defines the CLOB column
type as CLOB, but this is unsupported by Postgresql and should be TEXT instead.
Some googling suggests that this was already fixed for previous versions of
empire-db (at least in 2.0.7), but probably the fix got lost in refactorings
for version 2.2.0.
No other complaints so far ;-) Thanks a lot for this great project and
congratulations for promotion to TLP!
Regards,
Vladimir