The EPSG factory connected to a PostgreSQL 8.2 database works as expected. But connecting to the same database content on PostgreSQL 8.3 doesn't work anymore. We get the following exception:
This is because DirectEpsgFactory assigns a String parameter in a PreparedStatement for a column which is declared as integer in the database. Prior to PostgreSQL 8.3, the conversion was applied automatically. Starting with PostgreSQL 8.3, it is not anymore. From http://www.postgresql.org/docs/8.3/static/release-8-3.html:
"Previously, if a non-character value was supplied to an operator or function that requires text input, it was automatically cast to text, for most (though not all) built-in data types. This no longer happens: an explicit cast to text is now required for all non-character-string types."
The fix is to change the return value of the private toPrimaryKey(String) function from String to int and update the callers accordingly. In the main time, a workaround proposed by Mark Leslie is to redefine the integer -> text cast as implicit. See http://www.postgresql.org/docs/8.3/interactive/sql-createcast.html.