File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Character Encoding with DBCP pool" Watch "Character Encoding with DBCP pool" New topic

Character Encoding with DBCP pool

Olivier Debas

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(...,...,...);
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

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:
subject: Character Encoding with DBCP pool
It's not a secret anymore!