I have a Spring project and when i create a register user on table i have to create a database user too.
Now i have:
user = userRepository.save(user);
The command is:
CREATE USER 'username' IDENTIFIED BY 'password';
Is it possible?
You can do it like below:
//UserService
@Autowired
private JdbcTemplate jdbcTemplate;
...
user = userRepository.save(user);
jdbcTemplate.execute("CREATE USER \'username\' IDENTIFIED BY \'password\'");
Note that your datasource user defined in application properties should have suitable privileges to create user and etc.