问题
I do a call to an oracle stored procedure using JDBCTemplate which has an in/out parameter of STRUCT. One of the fields on this struct is a VARCHAR which gets updated depending on the stored procedure logic. However when this is returned from the call it just contains three question marks - '???'. This is possibly the work of the Riddler but it sounds more like a char encoding issue.
This worked fine until we switched databases to a database that had a character encoding of WE8ISO8859P15 (ISO8859) this was retrieved by doing:
SELECT NLS_CHARACTERSET FROM NLS_DATABASE_PARAMETERS
The previously working character set was WE8MSWIN1252 (MSWIN-1252) which works fine. So I'm guessing it's down to a char set issue although I'm slightly wary as it always returns just 3 question marks regardless of how much text should be returned.
As far as I understand the underlying JDBC driver (jdbc:oracle:thin) does all the character encoding automatically and converts the database char set to UTF-16 (Java char encoding) however it appears this is not happening. I'm using the StoredProcedure class (part of Spring) to call the StoredProcedure.
I've also tried adding the orai18n.jar to the classpath but with no success. However it seems really unusual considering ISO-8859 is a pretty standard charset so I might be going down the wrong path.
Any help would be greatly appreciated.
回答1:
This was a char encoding issue due to the database character encoding being stored as ISO-8859-15 - version 15 of this standard was causing all the problems which is essentially the addition of the Euro symbol. The oracle driver we were using to connect via JDBC simply couldn't do the conversion from ISO-8859-15 to Java's UTF-16.
Reverting back to ISO-8859-1 or changing to UTF-8 encoding on the database (better) resolves this. It's possible that adding the orai18n jar to the classpath may resolve this but as there is no readily availble OSGI bundle for this it wasn't as easily done. My recommendation is don't bother with Oracle databases at all.
来源:https://stackoverflow.com/questions/9400202/jdbc-call-to-oracle-returns-3-question-marks