Re: Sure: Bug with Encoding: \x80 \x81 ...
Posted by: Bambarbia Kirkudu
Date: June 02, 2007 09:29AM


It works with Asian characters without any extra URL parameters such as UTF-8. I tested with Statement and PreparedStatement, with Russian and Asian chars.

And it does not work with some characters in Java Unicode. If MySQL utf8 does not have any of Java Unicode, it must replace it with reverse question mark instead of throwing ERROR.

Here is the test case which works without "useUnicode=true&characterEncoding=UTF-8", MySQL Server has all utf8 by default:

package db.mysql;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;

public class TestConnection {
public static void main(String[] args) {
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://";

try {
System.out.println("Loaded this driver: " + driver);
} catch (Exception e) {
System.out.println("Can`t load this driver:" + driver);

try {
Connection conn = DriverManager.getConnection(url);
Statement st = conn.createStatement();
st.execute("DELETE FROM test");
st.execute("INSERT INTO test (text) VALUES ('Правительство меньшинства в Квебеке успешно закончило первый, самый...')");

PreparedStatement ps = conn.prepareStatement("INSERT INTO test (text) VALUES (?)");

ps.setString(1, "Правительство меньшинства в Квебеке успешно закончило первый, самый...");

String test = "淄博友好整形美容外科淄博山东美容整形吸脂除皱隆胸疤痕脱毛眼袋隆鼻面廓整形锯齿线除皱腋臭";
ps.setString(1, test);

ResultSet rs = st.executeQuery("SELECT text FROM test");

while (!rs.isLast()) {;


} catch (Exception ee) {
System.out.println("Can`t connect this Database,has this error:" + ee);

Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.