AmyAC
AmyAC

Reputation: 21

org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Wrong user name or password [28000-200]

Here is the error message.

    2020-06-15 13:10:23.623 ERROR 37317 --- [nio-8887-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Wrong user name or password [28000-200]
### The error may exist in tech/bootcamp/community/mapper/UserMapper.java (best guess)
### The error may involve tech.bootcamp.community.mapper.UserMapper.insert
### The error occurred while executing an update
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Wrong user name or password [28000-200]] with root cause

org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Wrong user name or password [28000-200]
at tech.bootcamp.community.controller.AuthorizeController.callback(AuthorizeController.java:52) ~[classes/:na]

@Autowired
private UserMapper userMapper;

it says this line causes the error.

        userMapper.insert(user);

So what's the user name and password actually are?

Upvotes: 1

Views: 18689

Answers (4)

jitendra varshney
jitendra varshney

Reputation: 3562

if we do not want to use default username(sa) and password("") than we need to define username and password in application.properties file example :-

spring.datasource.username=mydb
spring.datasource.password=mypass

you can use any username and any password if you want to use username other than sa , if you are using sa as a username then you need to define passwordf as a blank

Upvotes: 0

DevMateus
DevMateus

Reputation: 303

After running spring go to http://localhost:8080/h2-console/

Use same config JDBC URL: jdbc:h2:mem:testdb from your application properties

connect with empty user namer and password if you not set like answer above from DEWA Kazuyuki - 出羽和之.

User Name:
Password:

Upvotes: 1

Sangeeta
Sangeeta

Reputation: 11

The following worked for me as well.

spring.datasource.username=sa
spring.datasource.password=

Upvotes: 1

You can set on application.properties:

spring.datasource.username=dbuser
spring.datasource.password=dbpass

If not set explicitly, default values are used, "sa" and "".

Upvotes: 5

Related Questions