-2

I'm using ResultSet java.sql.Statement.executeQuery(String sql) throws SQLException

When I call this method, it is accent sensitive. How can I ignore this ?

String nom = "Labbe";// i want to find here "Labbe" and "Labbé" !
ResultSet resultSet = statement.executeQuery("Select * from Personne P Where P.nom = "+ nom);
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
mourad
  • 369
  • 1
  • 3
  • 9
  • you want to ignore *what*? Show your actual code please. – luk2302 Jan 18 '18 at 16:14
  • I added the code above, so i want to ignore the accent sensitive; like Labbé and Labbe. – mourad Jan 18 '18 at 16:24
  • by storing the phrase you are going to search for in lower case and without accents in the database in the first place. – luk2302 Jan 18 '18 at 16:25
  • yes but i want to a way to find in the database the name "Labbé" and "Labbe" both of them. In my case, i get just "Labbe" (without accent). How can i get the two results ? – mourad Jan 18 '18 at 16:30
  • Sorry, the problem i have is not the "case sensitive", but the "accent sensitive" – mourad Jan 18 '18 at 16:32
  • Possible duplicate of [Is there a way to get rid of accents and convert a whole string to regular letters?](https://stackoverflow.com/questions/3322152/is-there-a-way-to-get-rid-of-accents-and-convert-a-whole-string-to-regular-lette) – gengisdave Jan 18 '18 at 18:30
  • Which database are you using? – Mark Rotteveel Jan 18 '18 at 19:58
  • @gengisdave, no it is not the same subject, in my case i want to do that in the database query, (but thank you for the link) – mourad Jan 19 '18 at 09:56
  • @MarkRotteveel, I'm using H2 database – mourad Jan 19 '18 at 10:12

1 Answers1

0

You need to precede the statement with a PRIMARY strength for FRENCH or maybe ENGLISH.

SET COLLATION FRENCH STRENGTH PRIMARY;

See set collation. This will also help for list ordering, when not defined on the database schema.

Joop Eggen
  • 107,315
  • 7
  • 83
  • 138