0

I have a web application (jsf+hibernate) deployed on a tomcat server that tries to connect to MySQL database on another server, I have added the web app server ip to be allowed when connecting to the MySQL server, when I start the app I get

23:55:50,077  WARN SqlExceptionHelper:144 - SQL Error: 1142, SQLState: 42000
23:55:50,077 ERROR SqlExceptionHelper:146 - SELECT command denied to user 'xxx'@'yyyy' for table 'zzz'
org.hibernate.exception.SQLGrammarException: could not extract 

ResultSet
...

please note that, I have given the user all the privileges, also I can connect to the database from net beans and query normally. also running the web application and the mysql on local host, working fine.

Exorcismus
  • 2,243
  • 1
  • 35
  • 68
  • Have you read through the answers to similar questions? http://stackoverflow.com/questions/4767055/error-select-command-denied-to-user-useridip-address-for-table-table – Mark Leiber Apr 29 '15 at 15:49
  • I had checked all those, except for ... the table names, that is schema_table vs schema.table – Exorcismus Apr 29 '15 at 16:08
  • Did that resolve the issue? If not, do you know what SELECT statement is being run? – Mark Leiber Apr 29 '15 at 16:12
  • the query is generated by hibernate, I can't change that. and yes the query is select this_.id as id1_5_0_, this_.owner_type as owner_ty2_5_0_ from schema.newgar_ownership this_ – Exorcismus Apr 29 '15 at 16:18
  • Is "schema" your database name locally and on the remote server? – Mark Leiber Apr 29 '15 at 17:12
  • you'r right, it was the database host, they add a suffix prior to the schema name, which was conflicting in hibernate catalog, please change it to answer, so I can accept – Exorcismus Apr 29 '15 at 19:43

1 Answers1

1

Make sure you have the same database name locally and on the remote server. Often database hosts add a prefix or suffix to the database name that is in conflict with what you have in hibernate.

Mark Leiber
  • 3,118
  • 2
  • 13
  • 22