A
A
Arzonas2014-04-09 13:22:49
MySQL
Arzonas, 2014-04-09 13:22:49

MYSQL encoding - what's the problem?

There is a program written in java using webharvest 2.0 for self study. The program itself drags quotes and ratings ("..." and "???" counts as 0) to them with bash.im and hammers them into a database of the form:
idQuotes PK NN UN AI
Rating NN
Text
The program runs stably and exits when it wrote one page to the database. But in the table on MySQL, instead of Russian letters, it gives out "?" (English letters and numbers are normally displayed).
I send a query like this to the database: "INSERT INTO " + SchemaName + "." + TableName + " VALUES(NULL, rating, text)" The
program writes to the database through the java.sql package,

public void executeQuery(String query) {
        try {
            byte[] bytes = query.getBytes();              
            String str = new String(bytes, "UTF-8");  
            connection.createStatement().execute(str);    
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

In the database settings I tried to change to all kinds of encodings, it did not help.
System: Mac OS 10.9

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
svd71, 2014-04-09
@Arzonas

You need to configure the server to work with utf-8 .
Attention! This setting does not apply one-to-one to all versions of MySQL. You need to make a change in one parameter and check if the server starts at all. after that, check the encoding: writes to the new record correctly or not.

A
Arzonas, 2014-04-09
@Arzonas

thanks svd71!

[mysql]
default-character-set = utf8
init-connect="set names utf8"
skip-character-set-client-handshake
character-set-server = utf8
character-set-filesystem = utf8

[mysqld]
skip-character-set-client-handshake
character-set-server = utf8
character-set-filesystem = utf8

With this file my.cnf it worked

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question