This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

UTF-8 issue

 
Jordan Smith
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i use sql queries in my struts application.
since the information is in Hebrew i set the following settings:

1. db url: useUnicode=yes&characterEncoding=utf8
2. tomact catalina.sh: JAVA_OPTS="$JAVA_OPTS "-Dfile.encoding=utf-8"
3. in sql: i set the charcter encoding to UTF-8
4. server.xml on tomcat: useBodyEncodingForURI="true" URIEncoding="UTF-8"

but still, when i run it, i see in the log that it calls the DB with ??? values.
how can i solve the problem?
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
odelya yomtov-glick wrote:but still, when i run it, i see in the log that it calls the DB with ??? values.
how can i solve the problem?

This may be because your logger has not support to the UTF-8 encoding OR you're not setting the logger's property for the same.

Have you able to execute the queries successfully ?
 
Jordan Smith
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no.
i get the log:

DEBUG [http-12091-Processor25] - {pstm-100001} PreparedStatement: SELECT * FROM users WHERE NAME = ? AND PASSWORD = ?
DEBUG [http-12091-Processor25] - {pstm-100001} Parameters: [ביפר, ביפרילקוט]
DEBUG [http-12091-Processor25] - {pstm-100001} Types: [java.lang.String, java.lang.String]


which means that the characters are not being processed all right.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I repeat,
Sagar Rohankar wrote:Have you able to execute the queries successfully ?
 
Jordan Smith
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you - i fount the mistake
The problem was that I had:
useUnicode=yes&characterEncoding=utf8

instead of:

useUnicode=yes&characterEncoding=utf8

in the url
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
odelya yomtov-glick wrote:
The problem was that I had:
useUnicode=yes&characterEncoding=utf8

instead of:

useUnicode=yes&characterEncoding=utf8

ohh..
How I missed that, but its a problem here, I though you posted like "& a m p;" and JR software turn it like "&", even code tags convert it:

 
Jordan Smith
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ye
the browser converted it from "& a m p;" to &..
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Those look the same to me.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:Those look the same to me.

Yep, that's looks same to me too at first place, but when I it, everything gets clear :mrgreen:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic