title: Parameterized Oracle SQL query in Java?
body: <p>I've been trying to figure out why the following code is not generating any data in my ResultSet:</p>
  
  <pre><code>String sql = "SELECT STUDENT FROM SCHOOL WHERE SCHOOL = ? ";
  PreparedStatement prepStmt = conn.prepareStatement(sql);
  prepStmt.setString(1, "Waterloo");
  ResultSet rs = prepStmt.executeQuery();
  </code></pre>
  
  <p>On the other hand, the following runs properly:</p>
  
  <pre><code>String sql = "SELECT STUDENT FROM SCHOOL WHERE SCHOOL = 'Waterloo' ";
  PreparedStatement prepStmt = conn.prepareStatement(sql);
  ResultSet rs = prepStmt.executeQuery();
  </code></pre>
  
  <p>The data type for SCHOOL is CHAR (9 Byte). Instead of setString, I also tried:</p>
  
  <pre><code>String sql = "SELECT STUDENT FROM SCHOOL WHERE SCHOOL = ? ";
  PreparedStatement prepStmt = conn.prepareStatement(sql);
  String school = "Waterloo";
  Reader reader = new CharArrayReader(school.toCharArray());
  prepStmt.setCharacterStream(1, reader, 9);
  prepStmt.setString(1, "Waterloo");
  ResultSet rs = prepStmt.executeQuery();
  </code></pre>
  
  <p>I'm completely stuck on what to investigate next; the Eclipse debugger says the SQL query doesn't change even after setString or setCharacterStream. I'm not sure if it's because setting parameters isn't working, or if the debugger simply can't pick up changes in the PreparedStatement.</p>
  
  <p>Any help will be greatly appreciated, thanks!</p>