java Hibernate 部分请求连不上数据库
lxw西瓜 2018-11-16 05:06:17 最近开发遇到一个很神奇的错误,项目能正常启动,基本上所有对数据库操作都正常,唯独其中一个操作会触发数据库连接错误
[INFO ] HHH000397: Using ASTQueryTranslatorFactory (org.hibernate.hql.internal.QueryTranslatorFactoryInitiator)(http-bio-80-exec-2)(16:47:59,062)
[WARN ] [DEPRECATION] Encountered positional parameter near line 1, column 77 in HQL: [from com.** as model where model.**= ?]. Positional parameter are considered deprecated; use named parameters or JPA-style positional parameters instead. (org.hibernate.hql.internal.ast.HqlSqlWalker)(http-bio-80-exec-2)(16:47:59,149)
[WARN ] [DEPRECATION] Encountered positional parameter near line 1, column 77 in HQL: [from com.** as model where model.**= ?]. Positional parameter are considered deprecated; use named parameters or JPA-style positional parameters instead. (org.hibernate.hql.internal.ast.HqlSqlWalker)(http-bio-80-exec-5)(16:47:59,149)
[WARN ] SQL Error: 1045, SQLState: 28000 (org.hibernate.engine.jdbc.spi.SqlExceptionHelper)(http-bio-80-exec-5)(16:48:01,526)
[ERROR] Access denied for user '**'@'%' (using password: YES) (org.hibernate.engine.jdbc.spi.SqlExceptionHelper)(http-bio-80-exec-5)(16:48:01,526)
十一月 16, 2018 4:48:01 下午 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet [dispatcher] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.orm.hibernate5.HibernateJdbcException: JDBC exception on Hibernate data access: SQLException for SQL [n/a]; SQL state [28000]; error code [1045]; could not extract ResultSet; nested exception is org.hibernate.exception.GenericJDBCException: could not extract ResultSet] with root cause
java.sql.SQLException: Access denied for user '**'@'%' (using password: YES) …………
因为涉及项目,**代表具体包和用户名。
可以看到这段控制台报错,前面还有两句关于Hibernate数据库操作的警告,后面突然就出现连不上数据库,而且执行其他的请求触发数据库操作是没问题,定位到具体的DAO,很简单的一句
return hibernateTemplate.findByCriteria(detachedCriteria);
并没有去连不一样的数据库,从头到尾都是一个数据库。