title: setString for prepared statement not working
body: <p>I am trying to use the <code>setString(index, parameter)</code> method for Prepared Statements in order to create a <code>ResultSet</code> but it doesn't seem to be inserting properly. I know the query is correct because I use the same one (minus the need for the <code>setString</code>) in a later <code>else</code>. Here is the code I currently have:</p>
  
  <p>**From what I understand, the <code>ps.setString(1, "'%" + committeeCode + "%'");</code> is supposed to replace the <code>?</code> in the query but my output says otherwise. Any help is appreciated.</p>
  
  <pre><code>public String getUpcomingEvents(String committeeCode) throws SQLException{
          Context ctx = null;
          DataSource ds = null;
          Connection conn = null;
          PreparedStatement ps  = null;
          ResultSet rs = null;
  
      StringBuilder htmlBuilder = new StringBuilder();
      String html = "";
  
      try {
          ctx = new InitialContext();
          ds = (DataSource) ctx.lookup("java:ConnectDaily");
          conn = ds.getConnection();
  
          if(committeeCode != null){
              //get all events
              String queryStatement = "SELECT " + 
                      .......
                      "WHERE c.calendar_id = ci.calendar_id AND c.short_name LIKE ? " + 
                      "AND ci.style_id = 0 " + 
                      "AND ci.starting_date &gt; to_char(sysdate-1, 'J') " + 
                      "AND ci.item_type_id = cit.item_type_id " + 
                      "ORDER BY to_date(to_char(ci.starting_date), 'J')";
  
  
  
  
              ps = conn.prepareStatement(queryStatement);
  
              ps.setString(1, "'%" + committeeCode + "%'");
              System.out.println(queryStatement);
  
              rs = ps.executeQuery();
  
              if (rs != null){
                  while(rs.next()){
                      String com = rs.getString("name");
                      String comID = rs.getString("short_name");
  
                      String startTime = rs.getString("starting_time");
                      String endTime = rs.getString("ending_time");
                      String name = rs.getString("contact_name");
                      String desc = rs.getString("description");
                      String info = rs.getString("contact_info");
                      String date = rs.getString("directory");
  
                      htmlBuilder.append("&lt;li&gt;&lt;a href='?com="+committeeCode+"&amp;directory=2014-09-10'&gt;"+com+" - "+ date +" - "+startTime+" - "+endTime+"&lt;/a&gt; &lt;!-- Link/title/date/start-end time --&gt;&lt;br&gt;");
                      htmlBuilder.append("&lt;strong&gt;Location: &lt;/strong&gt;"+comID+"&lt;br&gt;");
                      htmlBuilder.append("&lt;strong&gt;Dial-In:&lt;/strong&gt;"+com+"&lt;br&gt;");
                      htmlBuilder.append("&lt;strong&gt;Part. Code:&lt;/strong&gt;"+info+"&lt;br&gt;");
                      htmlBuilder.append("&lt;a href='http://nyiso.webex.com'&gt;Take me to WebEx&lt;/a&gt;");
                      htmlBuilder.append("&lt;/li&gt;");            
                      }
              }
              html = htmlBuilder.toString();
  </code></pre>
  
  <p>.
  .
  .</p>
  
  <pre><code>    }catch (NamingException e) {
          e.printStackTrace();
          //log error and send error email
      } catch (SQLException e) {
          e.printStackTrace();
          //log error and send error email
      }finally{
          //close all resources here
          ps.close();
          rs.close();
          conn.close();
      }
      return html;
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Output</p>
  
  <pre><code>14:18:22,979 INFO  [STDOUT] SELECT  to_char(to_date(to_char(ci.starting_date), 'J'),'mm/dd/yyyy') as start_date,  to_char(to_date(to_char(ci.ending_date), 'J'),'mm/dd/yyyy') as end_date,  to_char(to_date(to_char(ci.starting_date), 'J'),'yyyy-mm-dd') as directory,  ci.starting_time,  ci.ending_time,  ci.description,  cit.description as location,  c.name,  c.short_name,  ci.add_info_url,  ci.contact_name,  ci.contact_info FROM calitem ci, calendar c, calitemtypes cit WHERE c.calendar_id = ci.calendar_id AND c.short_name LIKE ? AND ci.style_id = 0 AND ci.starting_date &gt; to_char(sysdate-1, 'J') AND ci.item_type_id = cit.item_type_id ORDER BY to_date(to_char(ci.starting_date), 'J')
  </code></pre>