try(JDBCSessionsession=DBUtils.openMetaSession(monitor,dataSource,"Change user password")){
session.enableLogging(false);
JDBCUtils.executeSQL(session,"ALTER USER "+DBUtils.getQuotedIdentifier(dataSource,userName)+" IDENTIFIED BY "+newPassword);// newPassword is unquoted, yes. That how it works in Oracle
}catch(SQLExceptione){
thrownewDBCException("Error changing user password",e);
// User can set new empty password, but then we will get an error when connecting with an empty password
thrownewDBException("Password change error for user: "+userName+". New password can not be empty.");
}
try(JDBCSessionsession=DBUtils.openMetaSession(monitor,dataSource,"Change user password")){
session.enableLogging(false);
JDBCUtils.executeSQL(session,"ALTER USER "+userName+" WITH PASSWORD "+SQLUtils.quoteString(dataSource,CommonUtils.notEmpty(newPassword)));
JDBCUtils.executeSQL(session,"ALTER USER "+DBUtils.getQuotedIdentifier(dataSource,userName)+" WITH PASSWORD "+SQLUtils.quoteString(dataSource,CommonUtils.notEmpty(newPassword)));
}catch(SQLExceptione){
thrownewDBCException("Error changing user password",e);
try(JDBCSessionsession=DBUtils.openMetaSession(monitor,dataSource,"Change user password")){
session.enableLogging(false);
JDBCUtils.executeSQL(session,"ALTER USER "+DBUtils.getQuotedIdentifier(dataSource,userName)+" SET PASSWORD ="+SQLUtils.quoteString(dataSource,CommonUtils.notEmpty(newPassword)));
}catch(SQLExceptione){
thrownewDBCException("Error changing user password",e);
try(JDBCSessionsession=DBUtils.openMetaSession(monitor,dataSource,"Change user password")){
session.enableLogging(false);
JDBCUtils.executeSQL(session,"ALTER USER "+DBUtils.getQuotedIdentifier(dataSource,userName)+" IDENTIFIED BY "+SQLUtils.quoteString(dataSource,CommonUtils.notEmpty(newPassword)));
}catch(SQLExceptione){
thrownewDBCException("Error changing user password",e);