My JRS repository is hosted by Postgres 9.3, but I need to use an 8.x driver. It’s not working. The application doesn’t load the license properly, and I see some problems in the log like:
java.io.StreamCorruptedException: invalid stream header: XXXXXXXX
How can I work around this issue?
Apparently, 9.x versions of Postgres have a new binary encoding algorithm for LOB fields. This changed a setting’s default value in 9.x (bytea_output); the 8.x driver doesn’t recognize the new encoding, and fails to read the value.
Two workarounds have been suggested:
- Option 1: Use the Postrgres 9.x JDBC driver instead of the 8.x version.
- Option 2: Reconfigure postgres instance to use 8.x default value.
For Option 2:
1- Edit the <postgres>\data\postgresql.conf file.
2 - Locate this line:
bytea_output = ' hex' # hex, escape
3 - Change : ' hex' to 'escape'. For example:
bytea_output = 'escape' # hex, escape
You need to make this change BEFORE any data is written to the database.
Note that this configuration affects everything in this Postgres instance. If other apps have databases in this Postgres instance, they will also need to be able to handle the ‘escape’ setting for the bytea_output option.