Problem with JDBC and euro ...

C

Canard Furieux

Hello,

update foo set data = "une ouvre de 10 000 ? \u20AC";
If I do this query directly in mysql control center the sentence is set
correctly.
If i do this via JDBC I got this: "une ½uvre de 10 000 ¤ ¤"
Both euro (\u20AC) and o (French char :Alt + 0156) are in charset
iso-8859-15 and I want to use this encoding...

Any clue ?

Using MySQL connector 3.0.11 on MySQL 4.0.* JDK 1.4.2
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.util.Properties;
public class foo {
private Connection cMySQL = null;
private Statement stmt = null;
public void connexionMySQL() {
try {
String dbURI = "jdbc:mysql://127.0.0.1/test";
Class.forName("com.mysql.jdbc.Driver").newInstance();
Properties prop = new Properties();
prop.put("charSet", "ISO-8859-15");
prop.put("characterEncoding", "ISO-8859-15");
prop.put("useUnicode", "true");
prop.put("user", "bob");
prop.put("password", "****");
cMySQL = DriverManager.getConnection(dbURI, prop);
stmt = cMySQL.createStatement();
} catch (Exception ex) {
System.out.println(ex);
}
}

public void closeMySQL() {
try {
cMySQL.close();
} catch (Exception ex) {
System.out.println(ex);
}
}

public foo() {
connexionMySQL();
try {
PreparedStatement pQuery = null;
pQuery = cMySQL.prepareStatement("update foo set "
+ "data = 'une ouvre de 10 000 ? \u20AC' ");
System.out.println(pQuery.toString());
pQuery.executeUpdate();
} catch (Exception ex) {
System.out.println(ex);
}
closeMySQL();
}

public static void main(String args[]) {
new foo();
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,076
Latest member
OrderKetoBeez

Latest Threads

Top