title: PreparedStatement with parameterised where clause in select statement throwing Exception
body: <p>I am getting exception as SQLException showing there is a something wrong in the syntax and check the manual for same.</p>
  
  <p>My java code is as follows.</p>
  
  <pre><code>PreparedStatement pst;
  String sql ="SELECT * FROM patient.medicine where _id=?";
  pst = cn.prepareStatement(sql);
      pst.setInt(1, 1);
  ResultSet rs = pst.executeQuery(sql);
  </code></pre>
  
  <p>If I execute this by appending the variable holding a value for id, everything works fine.</p>
  
  <pre><code>*SELECT * FROM patient.medicine where _name=?*
  Oct 19, 2013 11:15:46 AM com.seed.entity.Patient getData
  SEVERE: null
  com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in   your 
  
    SQL syntax; check the manual that corresponds to your MySQL server version for the 
    right syntax to use near '?' at line 1
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
  at java.lang.reflect.Constructor.newInstance(Unknown Source)
  at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
  at com.mysql.jdbc.Util.getInstance(Util.java:386)
  at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1053)
  at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096)
  at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)
  at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490)
  at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)
  at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2728)
  at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2678)
  at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1612)
  at com.seed.entity.Patient.getData(Patient.java:257)
  at com.seed.entity.Patient.main(Patient.java:360)
  </code></pre>