hibernate连接MySQL问题

来源:百度知道 编辑:UC知道 时间:2024/06/16 20:11:36
错误好像是说没有那张表,可是我明明通过hibernate把表映射成类了,不可能没有表的。
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:1596)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at com.hibernate.dao.UsersDao.getAllInfo(UsersDao.java:22)
at com.hibernate.dao.UsersDao.main(UsersDao.java:35)
Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 'zoutuo.zoutuo__users' doesn't exist
at com.mysql.jdbc.SQLError.createSQLExc

异常说的很明显啊,你的sql语法错了,你得用HQL执行query

报错的不是没有表,是执行语句有问题.
报错的代码是 不能执行查询,看看SQL语句写错没.

tx=session.beginTranscation();