This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Java in General and the fly likes Problems with accents in Java+Derby (Netbeans) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Problems with accents in Java+Derby (Netbeans)" Watch "Problems with accents in Java+Derby (Netbeans)" New topic
Author

Problems with accents in Java+Derby (Netbeans)

Marvin Legend
Ranch Hand

Joined: Oct 18, 2013
Posts: 35
Hello guys, I have a problem in Java + DerbySQL, I'm having trouble with accents, because when I search for a word that has accent, do not get results. I did a debug the code and noticed that the java (NetBeans IDE) puts in place the letter with the accent question mark (?) And at query time he seeks the word with this question in a word, or where the accent exists in my code is a string variable that receives the data entered by the user, and this variable is set in the SQL search string (example: ), I'm using the Derby database, I did the same search words with accents and worked properly at the derby console, inside the tab" Services "NetBeans, so I think the problem is in java, how to String variable P1 recognize accents and properly send the quest for the Derby? How can I solve this?
T.A. Nguyen
Ranch Hand

Joined: Sep 02, 2008
Posts: 36

Marvin Legend wrote:
...


You should be using a PreparedStatement and let the jdbc statement do all the escaping for you. This is also prevent SQL injection too. And your code should be:


T.A. Nguyen
http://ta.cnci.org
http://www.linkedin.com/in/nguyenta
 
GeeCON Prague 2014
 
subject: Problems with accents in Java+Derby (Netbeans)