Difference of character enconding Charset difference using JPA but not with prepared statement

1

I have an application using spring boot + oracle (via tomcat datasource). Using spring-data, a simple query in a table returns characters with an encoding problem.

This same application, in a very specific situation, I create a direct (no datasource) connection with JDBC and execute a query on the same table. But in this case, there is no problem with encoding.

Note: Before I thought it was just a problem with the front-end (some JS component), but checking the HTTP response by the browser, the data is already in trouble in the first case, but not in the second. p>

Sorry if this is a duplicate issue, but I could not find something similar. I know there are a lot of questions with oracle + java + charset, but my problem differs from the others I've encountered.

    
asked by anonymous 23.12.2016 / 01:13

1 answer

0

Identifying coding problems in a Java Web application

There are several assumptions that can only be validated with proper system verification.

  • The data is already corrupted in the database. In this case the problem is in receiving or recording the data.
  • The server may be decoding the request incorrectly.
    • Verify that enctype of the form on the page that sends the data is correct.
    • Verify that the browser sends the correct encoding in the request.
    • Verify that the application server is configured with proper encoding. Some application servers require the encoding to be defined before the decoding of the request values occurs, when you or the framework used first accesses those values. A common strategy is to use a servlet filter .
  • Data may be corrupted when it is written to the database.
    • Verify that the database table has the correct encoding. Banks like MySQL should default to utf8_general_ci encoding or similar.
    • Check the database driver documentation if the database connection settings, such as the connection URL, already exist or need to be added to configure the encoding .
  • The data is correct in the database, but it gets corrupted in Java. In this case it is a bad configuration of the connection to the bank.
    • Check the settings according to the previous connection to the bank.
  • The data is read correctly in Java, but it gets corrupted on the client. In this case it may be that the browser is decoding the request response with a different encoding than the server used to write the response.
    • Verify that the server sends the correct encoding in the response header. See the previous item on using a servlet filter .
    • Verify that the server actually encodes the correct response. See the previous item on using a servlet filter .
    • Check that there is a <meta> tag defining a encoding other than the HTTP header.
  • 24.12.2016 / 01:55