I perform the same sql scripts on two server with different postgres versions. The first one has postgres 9.4.4 (this works fine) and the other one 9.5 (this throws an exception) installed.
UPDATE archived_invoice SET encrypted_xml
= encrypt(xml::bytea, 'MySuperSecretKey'::bytea, 'aes-ecb/pad:pkcs')
The exception:
Caused by: org.postgresql.util.PSQLException: ERROR: invalid input syntax for type bytea
SQL Status:22P02
Are there any differences between these two postgresql versions?
standard_conforming_stringsdiffering between systems, which leads to different interpretation of backslashes. Anyway you should use theconvert_to()function to get bytes from text, as opposed to the cast to bytea. A cast does interpretation of escape sequences, which is completely off base here.