Hello
I have a problem.
I created database
create database mybase;
use mybase;
create table MYTABLE
(
ID bigint(10) not null,
NAME varchar(255) not null
)
comment = "Some table";
I using mysql-connector-java-3.1.6 и Mysql 4.1.9 on Windows 2000 Professional and Tomcat 4.1.31
I trying to run command INSERT or UPDATE with cyrillic symbol from JSP, but in table appear ??????
I trying to run command SELECT, but I get ??????? again.
Then I make insert through client mysql
INSERT INTO MYTABLE (ID, NAME) VALUES (2, 'Кириллические символы');
and I trying to get data again through JDBC and result is "2, ???????...", but through client mysql -
correct representation of symbols.
There are some piece of source
in top of JSP
<%@ page contentType="text/html;charset=windows-1251" %>
So I connect to database:
Connection conn = null;
Class.forName ("org.gjt.mm.mysql.Driver").newInstance();
String connectString = "jdbc:mysql://127.0.0.1:3306/mybase";
String user = "";
String password = "";
conn = DriverManager.getConnection(connectString, user, password);
So I run command INSERT
PreparedStatement pstmt = null;
String sql = "INSERT INTO MYTABLE (ID, NAME) VALUES (?, ?)";
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, 2);
pstmt.setString(2, "Кириллические символы");
pstmt.executeUpdate();
in database now 2 ????????????? ???????
So I run command SELECT
PreparedStatement pstm = null;
ResultSet rset = null;
pstm = conn.prepareStatement("select ID, NAME from MYTABLE");
rset = pstm.executeQuery();
if (rset.next()) {
out.print(rset.getString("ID") + " " + rset.getString("NAME"));
}
of course result is
2 ????????????? ???????
I tryed to connect so:
String connectString = "jdbc:mysql://127.0.0.1:3306/mybase?useUnicode=true&characterEncoding=Cp1251";
result is 2, ???????...
and/or created database with collation and charset
CREATE DATABASE db_name
DEFAULT CHARACTER SET cp1251 COLLATE cp1251_general_ci;
I got same result.
Perhaps problem is
http://bugs.mysql.com/bug.php?id=8231
Thank`s
Excuse me for my English