title: SELECT command denied to user 'user'@'localhost' for table 'table'
body: <p>I have deployed my database on MySQL Database server. I have a user 'bedgeaj_root@localhost' and it has all the permissions. But it still giving me the error :</p>
  
  <blockquote>
    <p>SELECT command denied to user 'bedgeaj_root'@'localhost' for table 'transactions'</p>
  </blockquote>
  
  <p>While searching on the net, I studied that it is some user permission issue. But I don't understand that why it is giving this error as I have given all the permission to this user.</p>
  
  <p>Here is the screen shot of my cPanel user permissions screen:</p>
  
  <p><img src="https://i.stack.imgur.com/3byo4.png" alt="bedgeaj_root@localhost permissions screen"></p>
  
  <p>Here goes my stack trace: </p>
  
  <pre><code>   Caused by: net.sf.jasperreports.engine.JRException: Error executing SQL statement for : itemizedStatementReport_patientBalance
  at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:246)
  at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:1073)
  at net.sf.jasperreports.engine.fill.JRFillDataset.initDatasource(JRFillDataset.java:667)
  at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1235)
  at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:859)
  at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:804)
  at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:652)
  at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:59)
  at net.sf.jasperreports.engine.fill.JRThreadSubreportRunner.run(JRThreadSubreportRunner.java:205)
  ... 1 more
  
  
     Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: SELECT command denied to user 'bedgeaj_root'@'localhost' for table 'transactions'
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
  at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
  at com.mysql.jdbc.Util.getInstance(Util.java:382)
  at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
  at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3603)
  at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3535)
  at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1989)
  at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2150)
  at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2626)
  at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
  at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2281)
  at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:239)
  ... 9 more
  </code></pre>
  
  <p>I am using this query:</p>
  
  <pre><code>    SELECT alias.patient_id , SUM(alias.balance) AS balance
      from (
      SELECT v.patient_id,trx.trx_id,trx.trx_status,trx.trx_seq,pb.billing_id,v.visit_id,v.visit_dt,forma t(SUM(tl.net_amount) - ifnull((SELECT SUM(pl.applied_amount+pl.discount_amount) FROM payment_lines pl where pl.trx_line_id = tl.trx_line_id),0.0),2)AS balance
      FROM ((transactions trx JOIN trx_lines tl ON (trx.trx_id = tl.trx_id))JOIN patient_billing pb ON(pb.billing_id = trx.billing_id))JOIN visits v ON (pb.visit_id = v.visit_id)
      where trx.trx_seq='4' AND trx.trx_status='PENDING' AND (date_format(v.visit_dt,'%Y/%m/%d')&lt;date_format(DATE_SUB(NOW(), INTERVAL 1 day),'%Y/%m/%d'))
      group by tl.trx_id) alias
      where alias.patient_id = $P{patient_id}
  </code></pre>
  
  <p>group by alias.patient_id]</p>
  
  <p>What I am doing wrong?</p>