0

WARN : org.hibernate.engine.jdbc.spi.SqlExceptionHelper - SQL Error: 0, SQLState: null ERROR:

org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES))

WARN : org.springframework.web.context.support.XmlWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException:

Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring/appServlet/dao-context.xml]: Invocation of init method failed; nested exception is org.hibernate.exception.GenericJDBCException: Unable to open JDBC

dataSource configue

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">

    <context:property-placeholder location="/WEB-INF/props/jdbc.properties" />

    <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
        destroy-method="close">
        <property name="driverClassName" value="${jdbc.driverClassName}" />
        <property name="url" value="${jdbc.url}" />
        <property name="username" value="${jdbc.username}" />
        <property name="password" value="${jdbc.password}" />
    </bean>

    <context:annotation-config></context:annotation-config>


    <context:component-scan base-package="kr.ac.hansung.cse.dao">
    </context:component-scan>


    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"></property>
        <property name="packagesToScan">
            <list>
                <value>kr.ac.hansung.cse.model</value>
            </list>
        </property>

        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.format_sql">false</prop>
            </props>
        </property>
    </bean>

    <tx:annotation-driven transaction-manager="transactionManager" />

    <bean id="transactionManager"
        class="org.springframework.orm.hibernate5.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>



</beans>

jdbc property files

jdbc.username=root
jdbc.password=root
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/estore

I can't open JDBC connection in spring. How can I fix them?

a bc
  • 43
  • 1
  • 1
  • 7
  • The exception is telling you what is wrong `Access denied for user 'root'@'localhost' (using password: YES)`. Either wrong password or you aren't allowed to remotely connect. – M. Deinum Jun 03 '18 at 07:14
  • @M.Deinum Thank you, but password is correct. what is other cause? – a bc Jun 04 '18 at 00:11
  • There was an **or** statement in my comment. If you password is correct you aren't allow to remotely connect. – M. Deinum Jun 04 '18 at 06:04
  • @M.Deinum Thank you, Do you know remotely Unconnectable status' cause? – a bc Jun 05 '18 at 05:40
  • Check the mysql manual on how to enable connecting from remote hosts. – M. Deinum Jun 05 '18 at 08:19

0 Answers0