使用spring获取数据源出现java.sql.SQLException: Access denied for user 'Administrator'@'localhost' (using password: YES)问题
使用spring获取数据源出现java.sql.SQLException: Access denied for user 'Administrator'@'localhost' (using password: YES)问题
driverClass=com.mysql.cj.jdbc.Driver
jdbcUrl=jdbc:mysql://localhost:3306/ssmbuild?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
username=root
password=123456
原因是因为username可能与系统变量同名导致,把username改成user就好了,然后再在spring中获取即可
<bean id="datasource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${driverClass}"/>
<property name="jdbcUrl" value="${jdbcUrl}"/>
<property name="user" value="${user}"/>
<property name="password" value="${password}"/>
<property name="maxPoolSize" value="30"/>
<property name="minPoolSize" value="10"/>
<property name="autoCommitOnClose" value="false"/>
<property name="checkoutTimeout" value="10000"/>
<property name="acquireRetryAttempts" value="2"/>
</bean>