Hello,
I use an MySQL 4.1.2 database server.
I execute Java queries with the connector 3.1.2.
As described in MySQL documentation the defaut caracter encoding is
latin1 or ISO8859_1:
CREATE TABLE `editeurs` (
`ns` int(11) unsigned NOT NULL auto_increment,
`nom` char(40) default NULL,
PRIMARY KEY (`ns`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
Command line : UPDATE `editeurs` SET `nom`="Denoël" WHERE `ns` = "10"
(second e with umlaut, ë in html convention)
When I read a string with accent, I get the good ones :
public String getEditeurs(String val) throws SQLException {
String editeur = null;
ResultSet res = stmt.executeQuery(
"select nom"
+ " from editeurs"
+ " where upper(nom) like \"%" +
val.toUpperCase()
+ "%\";");
if (res != null)
while (res.next()) {
editeur = res.getString("nom");
}
if (res != null) res.close();
return editeur;
}
=> Denoël : good e with umlaut.
But when I write a string with accent I got wrong caracter when I read
it again:
public int createEditeurs(String nom) throws SQLException {
return stmt.executeUpdate(
"insert into editeurs (nom)"
+ " values (\""
+ nom
+ "\");");
}
=> Deno‘l : bad caracter
Is there some configuration variable to set either in MySQL server or
on J-Connector?
Thanks in advance for your answers.
Best regards, Pascal.
http://perso.wanadoo.fr/blady
PS : I home you will read the accent in my e-mail.