Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

StackOverflow Point

StackOverflow Point Navigation

  • Web Stories
  • Badges
  • Tags
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Web Stories
  • Badges
  • Tags
Home/ Questions/Q 3661
Alex Hales
  • 0
Alex HalesTeacher
Asked: June 2, 20222022-06-02T22:17:28+00:00 2022-06-02T22:17:28+00:00

java – Spring JDBCTemplate returns broken characters instead of latin characters

  • 0

[ad_1]

I’m trying to get data with Latin characters in it which is like (‘ş’,’ç’,’ğ’,’ı’,’İ’,’Ü’)
but instead what i’m getting as output is ‘Ä�’ for ‘ğ’, ‘ç’ for ‘ç’
Whatever i try the output is weird.

 CASE WHEN type="a" THEN 'ğ ç ş'
 ELSE 'null' END AS description

The part of sql that i’m having trouble with is like as seen above. The problem is in that part when i logged my endpoint value of description looks weird from the very beginning.

Repository class which returns query values is like below.

public LPModel findLPInfo(String id) {
    LoyaltyProductModel list = jdbcTemplate
            .queryForObject(QueryConstants.GET_PL_INFO, new Object[]{id}, new LMapper());
    return list;
} 

My hibernate properties is below. I added charset details to fix my problem but that didn’t work.

spring.jpa.database-platform=org.hibernate.dialect.Oracle12cDialect
spring.datasource.driverClassName=oracle.jdbc.OracleDriver
spring.datasource.url=jdbc:oracle:thin:databaseName?useUnicode=true&characterEncoding=UTF-8&charSet=UTF-8
@PostMapping(value = "/getid", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<PostResponse> getid(@RequestBody LWRequest postRequest {

LoyaltyProductModel lpm = listRepository.findPromoLoyaltyProductInfo(postRequest.id);

String desc = String.valueOf(new String(lpm.DESCRIPTION.getBytes(), "UTF-8").getBytes("ISO-8859-1"));

log.info("Description " + lpm.DESCRIPTION);
}

End point is working and i added produces = MediaType.APPLICATION_JSON_UTF8_VALUE part just to be sure that response is in UTF-8 type.
i’m only showing relevant parts of my code about my problem.

i need to show output with exact characters like ğ ç ş

[ad_2]

  • 0 0 Answers
  • 8 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

Sidebar

Ask A Question

Related Questions

  • xcode - Can you build dynamic libraries for iOS and ...

    • 0 Answers
  • bash - How to check if a process id (PID) ...

    • 8057 Answers
  • database - Oracle: Changing VARCHAR2 column to CLOB

    • 1842 Answers
  • What's the difference between HEAD, working tree and index, in ...

    • 1924 Answers
  • Amazon EC2 Free tier - how many instances can I ...

    • 0 Answers

Stats

  • Questions : 43k

Subscribe

Login

Forgot Password?

Footer

Follow

© 2022 Stackoverflow Point. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.