Answer the question
In order to leave comments, you need to log in
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();
}
}
Answer the question
In order to leave comments, you need to log in
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.
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question