HHH000342:无法获取与查询元数据的连接:用户拒绝访问

时间:2015-10-29 13:15:35

标签: java mysql spring hibernate

我正在使用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)

我尝试了以下事项:

  1. 检查并重新检查我的密码。
  2. 授予对db
  3. root@localhost的完全访问权限

    这是日志:

    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
    

    这是我的数据源的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>
    

    以下是我的项目依赖项:

    <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>
    

    连接到同一数据库的同一工作区中的另一个项目工作得很好。它的主要区别在于它没有Apache POI依赖项。

    对此的任何帮助都会很棒。

1 个答案:

答案 0 :(得分:2)

我能够在这里找出问题所在。显然我使用的是较旧版本的数据库模式,该模式没有一些代表(后来的版本)预期的表。