Reputation: 799
I'm trying to login to postgres via admin user. How to update the password of a normal user using java?
Upvotes: 0
Views: 407
Reputation: 247950
You can run
ALTER ROLE rolename PASSWORD 'newpassword'
But there is a danger there. Unless you are using an encrypted database connection, the password will be sent in clear text and may end up in the PostgreSQL log file.
So the better option is to hash the password before you send it so the server. Unfortunately the JDBC driver does not provide functions to do that, so you would have to rewrite that code in Java.
Upvotes: 3