utf8 data getting converted to Latin encoding
Posted by: Himanshu Vasishth
Date: September 03, 2009 07:41PM

I am trying to insert utf8 data into my database using the code below. However, this code seems to work on some machines and doesn't work on others.

The column on the database uses utf8 character set and utf8_general_ci collation.

this.connection = this.dataSource.getConnection();
this.connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
this.connection.setAutoCommit(false);
this.threadId = Thread.currentThread().getId();
Statement stmt = this.connection.createStatement();
stmt.execute("SET NAMES 'utf8'");
PreparedStatement ps =
conn.prepareStatement(
"INSERT INTO Comments " +
"(Body) " +
"VALUES (?)",
ResultSet.TYPE_FORWARD_ONLY,
Statement.RETURN_GENERATED_KEYS);
ps.setString(1, bodyStr);

Options: ReplyQuote


Subject
Views
Written By
Posted
utf8 data getting converted to Latin encoding
3560
September 03, 2009 07:41PM


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.