title: JDBC is throwing grammar error when the query is working in php myadmin
body: <p>I am working on java website using jdbc for mysql. Here is my simple function to fetch data from sql,</p>
  
  <pre><code>@Override
      public List fetchMusic(String _uname, String _chnl_name) throws SQLException {
  
          String sql = "SELECT * FROM `channel_songs` WHERE `uid` = " +
                       " (SELECT `id` FROM `user` WHERE BINARY `uname` = ?)"+
                       " AND `chnl_id` = (SELECT `id` FROM `channel` WHERE BINARY `chnl_name` = ?);";
  
          Connection conn = dataSource.getConnection();
  
          PreparedStatement ps = conn.prepareStatement(sql);
  
          ps.setString(1, _uname);
          ps.setString(2, _chnl_name);
  
          List&lt;Map&lt;String, Object&gt;&gt; musicListsByChnl = jdbcTemplate.queryForList(String.valueOf(ps));
  
  
          return musicListsByChnl;
  
      }
  </code></pre>
  
  <p>So, when I am running this, I am getting an error which says,</p>
  
  <pre><code>org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [com.mysql.jdbc.JDBC4PreparedStatement@3a4eb50a: SELECT * FROM `channel_songs`]; nested exception is 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 'com.mysql.jdbc.JDBC4PreparedStatement@3a4eb50a: SELECT * FROM `channel_songs`' at line 1
  </code></pre>
  
  <p>So, I don't know what is wrong or where it is. When I am trying this query on phpmyadmin, it is working properly and returning the data. So can anyone help me here?</p>
  
  <p>Thanx in advance. ;)</p>