SQL Error: 0, SQLState: 08S01 和Communications link failure

bug:

WARN : org.hibernate.engine.jdbc.spi.SqlExceptionHelper - SQL Error: 0, SQLState: 08S01
ERROR: org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Communications link failure

一开始使用的数据源配置如下

id="dataSource"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url"
value="jdbc:mysql://localhost:3306/db_heybar01?useUnicode=true&characterEncoding=UTF-8"/>
<property name="username" value="test"/>
<property name="password" value="test"/>

通过错误信息以及搜索初步判断是数据库的连接数不够用的,试着换了一下连接池:
修改后的数据源配置:

<bean id="dataSource"
          class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    <property name="driverClass">
        <value>com.mysql.jdbc.Drivervalue>
    property>
    <property name="jdbcUrl">
        <value>jdbc:mysql://101.201.73.167:3306/db_heybar01?useUnicode=true&characterEncoding=UTF-8value>
    property>
    <property name="properties">
        <props>
            <prop key="c3p0.minPoolSize">2prop>
            <prop key="c3p0.maxPoolSize">50prop>
            <prop key="c3p0.timeout">5000prop>
            <prop key="c3p0.max_statement">100prop>
            <prop key="c3p0.testConnectionOnCheckout">trueprop>
            <prop key="user">nupa01prop>
            <prop key="password">NUPA_mysql_2017prop>
        props>
    property>
bean>

你可能感兴趣的:(java,hibernate,MySQL)