wood burning stoves 2.0*
The moose likes Tomcat and the fly likes Character Encoding with DBCP pool Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Character Encoding with DBCP pool" Watch "Character Encoding with DBCP pool" New topic
Author

Character Encoding with DBCP pool

Olivier Debas
Greenhorn

Joined: Oct 30, 2007
Posts: 2
I'm migrating a servlet/JSP application from ISO-8859-1 to UTF-8.
I use Mysql 5.0.45 which is UTF-8 configured and Tomcat 5.5.12.
I manage to read UTF-8 characters from database and display them in HTML page.
Submitting form data with UTF-8 character is also successful.
The problem is when i execute an update query, UTF-8 characters in SQL request are damaged. Problem occurs in JVM around DBCP and jdbc driver, not in database.

I tested direct use of driver with DriverManager like this :
Connection co = DriverManager.getConnection(...,...,...);
co.createStatement().executeUpdate(query);
and it's ok, UTF-8 characters are written correctly in database.

If i use connection from DBCP pool, character UTF-8 are considered as ISO 8859-1.

If a run Tomcat with -Dfile.encoding=UTF-8 JVM option, everything is ok ; but i can't use this work around because other applications use ISO 8859-1.

Someone has idea ? Thank's in advance
Olivier Debas
Greenhorn

Joined: Oct 30, 2007
Posts: 2
When i use directly DBCP in my application to obtain connection, characters are well encoded in UTF-8.
When i use datasource which is set up in Tomcat, character are damaged with ISO 8859-1 encoding.
It seems that using Datasource is the cause of problems...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Character Encoding with DBCP pool
 
Similar Threads
Handling languages other than English in Java ...........................
String encoding problem
Need to add an invalid UTF-8 character
Problem while storing Japanese characters in Oracle 9i
Uploaded files have characters changed !!!