'Spring using windows user instead of given username 'root' to hit the mysql

Getting the error

"Access denied for user 'DEll'@'localhost' (using password: YES)"

In the spring xml file I have given the user as 'root' not dell. I have tried everything. I believe there will be simple solution for this.

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

The property file is

driverClassName=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/test
username=root
password=12345


Solution 1:[1]

It seems you've discovered USERNAME is already a reserved system environment variable. Maybe because you're on windows, the case insensitity is finding the lowercase version

Try changing your property and reference to:

user=root and <property name="username" value="${user}"></property>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dovmo