N
N
Natalia Tsarkevich2014-02-01 01:24:28
MySQL
Natalia Tsarkevich, 2014-02-01 01:24:28

How to deal with the Cyrillic record in the database?

I can save/edit data in a table from the database, if I enter Russian text, it saves it in this form:
Ð²Ð¾Ñ Ñак ÑоÑÑанÑеÑÑÑ ÑÑÑÑкий ÑекÑÑ
DB - MySQL, driver connector/J-driver 5.1.1 itself fields utf-8 encoding of the jsf page is also in this encoding.
What to add, I think there are those who had similar problems.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Nikolai Turnaviotov, 2014-02-01
@foxmuldercp

the first is the encoding of the web page.
the second is a collation at the base itself.
the third - the coding yes, fields.

A
Alexander, 2014-02-01
@alexyat

There was a similar question, we solved it Why are there question marks instead of Russian letters in PDO when inserting data into the database?

D
DiLighteR, 2014-02-01
@DiLighteR

jsf pages are also in this encoding

most likely you mean that at the beginning of the xhtml page there is something like this
that just tells the xml parser what encoding the source page itself is written in, and has nothing to do with what encoding the entered data is transmitted to the server in.
try a filter that forces all requests to utf-8 encoding
@WebFilter("/*")
public class CharacterEncodingFilter implements Filter {

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        chain.doFilter(request, response);
    }

    // ...
}

if it does not help, you need to configure the request encoding on your application server.
Specifically, in the case of glassfish, this glassfish-web.xml helped me
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app error-url="">
  <class-loader delegate="true"/>
  <jsp-config>
    <property name="keepgenerated" value="true"/>
  </jsp-config>
  <glassfish-web-app>
  <parameter-encoding default-charset="UTF-8" />
</glassfish-web-app>
</glassfish-web-app>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question