1
votes

Saving the text “février.xlsx” in DB is getting saved as “février.xlsx” when saved via J2EE application.

DB Version : Oracle Database 11g Enterprise Edition Release 11.2.0.4.0

NLS_CHARACTERSET - AL32UTF8

NLS_NCHAR_CHARACTERSET - AL16UTF16

public DocumentModel save(DocumentModel model) {
                  DocumentModel docModel = null;
                  try {
                         LOGGER.info("Name before saving into DB :"+model.getDocumentFileName());
                         docModel = entityManager.merge(model);
                  } catch (Exception exp) {
                         LOGGER.error("Exception occured");
                            }
                  return docModel;
           }

Column Datatype in Table : VARCHAR2(256 CHAR)

Name before saving into DB : février.xlsx

Name saved DB : février.xlsx

I have tried to inserted in DB manually with insert statement. It is getting inserted correct but when inserted from application it's incorrect.

1
Could it be that your application is setting the session NLS character set to something that is not compatible? Do you have any means of verifying the NLS settings for the application?Steve

1 Answers

0
votes

The difficulty is always to determine if the wrong value is stored in the database or if the correct value is stored in the database. There is always the chance that the error occurs when displaying the retrieved value.

Oracle has the function dump().

select dump(column),column from table;

This will show you the byte values as they are actually stored in the database. Using this you can check if these values are the correct values given the character you want to store and the database characterset.

http://docs.oracle.com/cd/E11882_01/server.112/e41084/functions055.htm#SQLRF00635