0

I need to fetch multilingual data from Oracle DB. As I have checked from sql developer the data when stored in Oracle tables are in correct format but when I try to fetch it using my Spring Boot application uisng queries it gets encrypted. Any suggestions how can I fetch same data in same format in my Java application?

For example String ' is converted to & apos ; (adding space)

@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)
public List<CustomerTrigger> fetchTriggerDetails(String queryForTrigger)
        throws COException {
    List<CustomerTrigger> triggersList = null;

    try {
        triggersList = coJdbcTemplate.query(queryForTrigger,
                new BeanPropertyRowMapper<CustomerTrigger>(
                        CustomerTrigger.class));
        // if triggerListis not empty then only update
        if (null != triggersList && !triggersList.isEmpty()) {
            List<String> queryTriggerList = new ArrayList<>();
            for (CustomerTrigger CustomerTrigger : triggersList) {
                List<String> list= Arrays.asList(CustomerTrigger.getEventId().
                        split(StringConstants.COMMA_SEPERATOR));
                queryTriggerList.addAll(list);

            }        
        }

    } catch (DataAccessException e) {
        logger.error("Error while updating records" + e.getMessage());
        e.printStackTrace();
        MyException myException = new MyException(
                ErrorConstants.TM_SQL_EXCEPTION_ERROR_CODE,
                ErrorConstants.TM_SQL_EXCEPTION_ERROR_CODE
                        + StringConstants.COLON + e.getMessage());
        throw myException;
    }

    return triggersList;
}
Loren
  • 320
  • 1
  • 10
  • 25
  • Could you clarify what you mean by "it gets encrypted"? That sounds unlikely. Please show *exactly* how you're observing the data - it's entirely possible that it's being fetched fine, and it's the way that you're displaying it that's causing a problem. – Jon Skeet Jun 23 '20 at 05:34
  • @JonSkeet Edited my question with one sample data – Loren Jun 23 '20 at 05:41
  • @JonSkeet When I am saving my edits here the encoded string is getting converted to its original value ' – Loren Jun 23 '20 at 05:55
  • 1
    That's just XML escaping. There are all kinds of reasons that could happen. Unfortunately you still haven't told us anything about how you're observing the data. Please show us code and give more details. – Jon Skeet Jun 23 '20 at 06:44
  • See [Recommended method for escaping HTML in Java](https://stackoverflow.com/questions/1265282/recommended-method-for-escaping-html-in-java) –  Jun 23 '20 at 07:27
  • @JonSkeet I have Added code snippet . – Loren Jun 23 '20 at 07:43
  • That's shown us how you've fetched the data. It hasn't told us anything about how you're *observing* the `'` value. – Jon Skeet Jun 23 '20 at 07:46
  • From that list fetching values like this String regAccount = tranMessage.getRegAccount(); in loop – Loren Jun 23 '20 at 08:11
  • @saka1029 Not working for me – Loren Jun 23 '20 at 08:17
  • String regAccount = tranMessage.getRegAccount(); // O'HX000243 String escaped=HtmlUtils.htmlEscape(regAccount); System.out.println(escaped); // O&apos;HX000243 – Loren Jun 23 '20 at 08:17

0 Answers0