java HHH000342:无法获得查询元数据的连接:用户拒绝访问
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33415305/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HHH000342: Could not obtain connection to query metadata : Access denied for user
提问by kl27driver
I am working on an application with Spring 4.1.6 and Hibernate 4.3. When deploying my application on the test server (Tomcat7) in Eclipse I get the following error:
我正在使用 Spring 4.1.6 和 Hibernate 4.3 开发一个应用程序。在 Eclipse 中的测试服务器 (Tomcat7) 上部署我的应用程序时,出现以下错误:
015-10-29 18:15:28 WARN JdbcServicesImpl:204 - HHH000342: Could not obtain connection to query metadata : Access denied for user 'root'@'localhost' (using password: YES)
I have tried out the following things :
我已经尝试了以下事情:
- Checked and rechecked my password.
- Granted full access to
root@localhost
on the db
- 检查并重新检查了我的密码。
- 授予
root@localhost
对 db 的完全访问权限
Here is the log:
这是日志:
2015-10-29 18:15:22 INFO XmlWebApplicationContext:510 - Refreshing WebApplicationContext for namespace 'recruitment-mvc-servlet': startup date [Thu Oct 29 18:15:22 IST 2015]; root of context hierarchy
2015-10-29 18:15:23 INFO XmlBeanDefinitionReader:317 - Loading XML bean definitions from ServletContext resource [/WEB-INF/recruitmentapp-context-config.xml]
2015-10-29 18:15:24 INFO XmlBeanDefinitionReader:317 - Loading XML bean definitions from ServletContext resource [/WEB-INF/recruitmentapp-multitenancy-config.xml]
2015-10-29 18:15:24 INFO DefaultListableBeanFactory:822 - Overriding bean definition for bean 'loginController': replacing [Generic bean: class [com.ta.app.recruitment.web.controller.LoginController]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [F:\Work\dev\svn\Recruitment Workspaces\Release_1.1_29_10_2015\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Recruitment\WEB-INF\classes\com\ta\app\recruitment\web\controller\LoginController.class]] with [Generic bean: class [com.ta.app.recruitment.web.controller.LoginController]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in ServletContext resource [/WEB-INF/recruitmentapp-context-config.xml]]
2015-10-29 18:15:24 INFO DefaultListableBeanFactory:822 - Overriding bean definition for bean 'candidateController': replacing [Generic bean: class [com.ta.app.recruitment.web.controller.CandidateController]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [F:\Work\dev\svn\Recruitment Workspaces\Release_1.1_29_10_2015\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Recruitment\WEB-INF\classes\com\ta\app\recruitment\web\controller\CandidateController.class]] with [Generic bean: class [com.ta.app.recruitment.web.controller.CandidateController]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in ServletContext resource [/WEB-INF/recruitmentapp-context-config.xml]]
2015-10-29 18:15:24 INFO DefaultListableBeanFactory:822 - Overriding bean definition for bean 'interviewerController': replacing [Generic bean: class [com.ta.app.recruitment.web.controller.InterviewerController]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [F:\Work\dev\svn\Recruitment Workspaces\Release_1.1_29_10_2015\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Recruitment\WEB-INF\classes\com\ta\app\recruitment\web\controller\InterviewerController.class]] with [Generic bean: class [com.ta.app.recruitment.web.controller.InterviewerController]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in ServletContext resource [/WEB-INF/recruitmentapp-context-config.xml]]
2015-10-29 18:15:24 INFO DefaultListableBeanFactory:822 - Overriding bean definition for bean 'recruiterController': replacing [Generic bean: class [com.ta.app.recruitment.web.controller.RecruiterController]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [F:\Work\dev\svn\Recruitment Workspaces\Release_1.1_29_10_2015\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Recruitment\WEB-INF\classes\com\ta\app\recruitment\web\controller\RecruiterController.class]] with [Generic bean: class [com.ta.app.recruitment.web.controller.RecruiterController]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in ServletContext resource [/WEB-INF/recruitmentapp-context-config.xml]]
2015-10-29 18:15:24 INFO DefaultListableBeanFactory:822 - Overriding bean definition for bean 'searchController': replacing [Generic bean: class [com.ta.app.recruitment.web.controller.SearchController]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [F:\Work\dev\svn\Recruitment Workspaces\Release_1.1_29_10_2015\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Recruitment\WEB-INF\classes\com\ta\app\recruitment\web\controller\SearchController.class]] with [Generic bean: class [com.ta.app.recruitment.web.controller.SearchController]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in ServletContext resource [/WEB-INF/recruitmentapp-context-config.xml]]
2015-10-29 18:15:24 INFO DefaultListableBeanFactory:822 - Overriding bean definition for bean 'staticController': replacing [Generic bean: class [com.ta.app.recruitment.web.controller.StaticController]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [F:\Work\dev\svn\Recruitment Workspaces\Release_1.1_29_10_2015\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Recruitment\WEB-INF\classes\com\ta\app\recruitment\web\controller\StaticController.class]] with [Generic bean: class [com.ta.app.recruitment.web.controller.StaticController]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in ServletContext resource [/WEB-INF/recruitmentapp-context-config.xml]]
2015-10-29 18:15:26 INFO PropertySourcesPlaceholderConfigurer:172 - Loading properties file from class path resource [dbparams.properties]
2015-10-29 18:15:26 INFO DriverManagerDataSource:133 - Loaded JDBC driver: com.mysql.jdbc.Driver
2015-10-29 18:15:27 INFO Version:66 - HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
2015-10-29 18:15:27 INFO Version:54 - HHH000412: Hibernate Core {4.3.2.Final}
2015-10-29 18:15:27 INFO Environment:239 - HHH000206: hibernate.properties not found
2015-10-29 18:15:27 INFO Environment:346 - HHH000021: Bytecode provider name : javassist
Datasource : org.springframework.jdbc.datasource.DriverManagerDataSource@18229761
2015-10-29 18:15:28 WARN JdbcServicesImpl:204 - HHH000342: Could not obtain connection to query metadata : Access denied for user 'root'@'localhost' (using password: YES)
2015-10-29 18:15:28 INFO Dialect:145 - HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
2015-10-29 18:15:28 INFO LobCreatorBuilder:88 - HHH000422: Disabling contextual LOB creation as connection was null
2015-10-29 18:15:29 INFO TransactionFactoryInitiator:62 - HHH000399: Using default transaction strategy (direct JDBC transactions)
2015-10-29 18:15:29 INFO ASTQueryTranslatorFactory:47 - HHH000397: Using ASTQueryTranslatorFactory
2015-10-29 18:15:32 DEBUG MapperFactory:49 - Entering >> getMapperInstance()
2015-10-29 18:15:32 DEBUG MapperFactory:50 - Parameters : jd.mapper
2015-10-29 18:15:32 DEBUG EntityDTOMapper:62 - Entering >> constructor addressMapper
2015-10-29 18:15:32 DEBUG MapperFactory:49 - Entering >> getMapperInstance()
2015-10-29 18:15:32 DEBUG MapperFactory:50 - Parameters : skill.category.mapper
2015-10-29 18:15:32 DEBUG MapperFactory:67
Here is my spring config file entry for the datasource:
这是我的数据源的 spring 配置文件条目:
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${database.driver}" />
<property name="url" value="${database.url}" />
<property name="username" value="${database.user}" />
<property name="password" value="${database.password}" />
</bean>
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<map>
<entry key="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<entry key="hibernate.show_sql" value="${hibernate.show_sql}" />
<entry key="hibernate.connection.CharSet" value="utf8" />
<entry key="hibernate.connection.characterEncoding" value="utf8" />
<entry key="hibernate.multiTenancy" value="SCHEMA" />
<entry key="hibernate.multi_tenant_connection_provider"
value-ref="tenantConnectionProvider" />
<entry key="hibernate.tenant_identifier_resolver" value-ref="tenantIdentifierResolver"></entry>
</map>
</property>
Here are my project dependencies:
这是我的项目依赖项:
<properties>
<spring.version>4.1.6.RELEASE</spring.version>
<hibernate.version>4.3.2.Final</hibernate.version>
<log4j.version>1.2.17</log4j.version>
<jdk.version>1.7</jdk.version>
<json.version>2.4</json.version>
<servlet.version>3.0.1</servlet.version>
<jsp.version>2.2.1</jsp.version>
<jstl.version>1.2</jstl.version>
<shiro.version>1.2.3</shiro.version>
<context.path>Recruitment</context.path>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-web</artifactId>
<version>${shiro.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
<version>${shiro.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring</artifactId>
<version>${shiro.version}</version>
</dependency>
<dependency>
<groupId>com.ta.app.recruitment</groupId>
<artifactId>recruitment.core</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>${json.version}</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>${jsp.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>3.8</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>1.8.9</version>
</dependency>
<dependency>
<groupId>net.sf.cssbox</groupId>
<artifactId>pdf2dom</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
</dependencies>
Another project in the same workspace connecting to the same database works just fine. Its main difference is that it does not have the Apache POI dependencies.
连接到同一数据库的同一工作区中的另一个项目工作正常。它的主要区别在于它没有 Apache POI 依赖项。
Any help on this would be great.
对此的任何帮助都会很棒。
回答by kl27driver
I was able to figure out the issue here. Apparently I was using an older version of the database schema that did not have a couple of tables that the code (which was a later version) expected.
我能够在这里找出问题所在。显然,我使用的是旧版本的数据库模式,它没有代码(更高版本)所期望的几个表。