title: How to sort results case-insensitive in Oracle SQL?
body: <p>The classic way to query an SQL database case-insensitively from Java is as follows:</p>
  
  <pre><code>String name = ...;  // get the user's input (case is unknown)
  String sql = "select * from Person where lower(name) = ?";
  Object jdbcBindVariable = name.toLowerCase();
  // ... using JDBC, bind that variable and run the SQL query
  </code></pre>
  
  <p>The problem is that lower-casing is a locale-specific operation. For example, lower-casing the letter "<code>I</code>" gives different results in English and Turkish. In the above code, there are two lower-casing operations:</p>
  
  <ul>
  <li>The String#toLowerCase() method</li>
  <li>The lower() database function</li>
  </ul>
  
  <p>How can I make sure that Java and the database are using the same locale and thereby performing a valid comparison? </p>
  
  <p>I'm aware that the String class has a toLowerCase(Locale) method, but how do I know what Locale the database is using? Can I check this programatically, or do I have to hard-code the locale to the one with which I think the database (in this case Oracle 10g) is configured?</p>