title: " nested exception is java.sql.SQLException: Incorrect syntax near '?' "
body: <p>I'm trying to execute a SQL statement in my Java application via the <code>JdbcTemplate</code> of Spring Framework. I am getting a <code>"bad SQL grammar"</code> error despite the query working 100% fine in Aqua Data Studio.</p>
  
  <p>Here is my Java code:</p>
  
  <pre><code>String entity = GCEnvironmentClient.getGteProperties().getProperty("ENTITY_ID");
  
  InputStream is = Thread.currentThread().getContextClassLoader()
              .getResourceAsStream("sql/blotter.sql");
  
      String query = IOUtils.toString(is).concat(entity);
  
      return this.jdbcTemplate.query(query, new BlotterTradeMapper());
  </code></pre>
  
  <p>One thing to note: I tried making my <code>RowMapper</code> class (<code>BlotterTradeMapper</code>) return <code>null</code> objects to avoid manipulating the <code>ResultSet</code>. This didn't change anything, so I know this class isn't causing issues.</p>
  
  <p>Here is the query:</p>
  
  <pre><code>SELECT 
      inv..trans.com_line1,
      inv..trans.trade_acct,
      inv..trans.bs_code,
      inv..trans.trans_type,
      inv..trans.cust_num,
      mast..sec_mst.sec_type,
      mast..sec_mst.mature_date,
      mast..sec_mst.coupon,
      inv..trans.trans_num,
      inv..trans.trade_date,
      inv..trans.cc_code,
      inv..trans.settle_date,
      inv..trans.other_chrg,
      inv..trans.principal,
      inv..trans.interest,
      inv..trans.basis_prc,
      inv..trans.dollar_prc,
      inv..trans.quantity,
      inv..trans.cusip,
      inv..trans.rem_line1,
      inv..trans.rem_line2,
      mast..sec_mst.dated_date,
      mast..sec_mst.des_line1,
      mast..groupmst.group_name,
      mast..groupmst.group_id,
      mast..cust_mst.nam_add1,
      inv..trans.fin_rate,
      ISNULL(mast..contract.contract_size, 1),
      ISNULL(mast..contract.contract_size, 1),
      mast..curr_mst.multiplier,
      mast..sec_mst.sec_class
  FROM 
      inv..trans,
      mast..sec_mst,
      mast..cust_mst,
      mast..groupmst,
      mast..curr_mst,
      mast..contract
  WHERE 
      inv..trans.cust_num = mast..cust_mst.cust_num 
  AND 
      inv..trans.group_id = mast..groupmst.group_id 
  AND 
      inv..trans.cusip = mast..sec_mst.cusip 
  AND 
      mast..sec_mst.currency_type = mast..curr_mst.currency_type
  AND 
      mast..sec_mst.contract_code *= mast..contract.contract_code
  AND
      inv..trans.entity_id = 1
  </code></pre>
  
  <p>Here is the error:</p>
  
  <pre><code>org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [query]; nested exception is java.sql.SQLException: Incorrect syntax near '?'. at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:237)
  </code></pre>
  
  <p>Note that there are no question marks in the query! Has anyone seen something like this before?</p>