Subject | Re: UNICODE_FSS, internationalization issue |
---|---|
Author | Panagiotis Konstantinidis |
Post date | 2003-07-10T10:35:33Z |
> You are right - as I wrote before, all SQL statements are convertedcorrectly.
> using defaul JVM encoding. All _parameters_ are converted
> Please post your code with PreparedStatement to check if this isthe case.
Well JAVA default encoding is 8859_7 (as it should because my most
web apps run in that character set).
Now I have an internationalized web app which I want to run in UTF-
8. So my HTML FORMS post data in UTF-8 and my servlets which write
to the database set request character encoding to UTF-8. (that way
servlets read parameters properly) My JDBC connection is also set to
UNICODE_FSS and the database is created using character set
UNICODE_FSS. That way when I call PreparedStatement.executeUpdate()
the driver should not convert parameters to java default encoding
but to JDBC encoding or at least the database encoding (in both
cases UNICODE_FSS).
Pseudocode of the servlet follows :
doInsert {
request.setCharacterEncoding("UTF-8");
String newsCode = request.getParameter("newsCode");
String newsTitle= request.getParameter("newsTitle");
String newsText= request.getParameter("newsText");
get a db connection with lc_ctype=UNICODE_FSS;
String query = "INSERT INTO newsTab
(newsCode,newsTitle,newsText) VALUES (?,?,?)";
database.createPreparedStatement(query);
ps.setString(1, newsCode);
ps.setString(2, newsTitle);
ps.setString(3, newsText);
ps.executeUpdate();
......
......
......
}