Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How do I code "ALTER USER USER IDENTIFIED BY ? REPLACE ?" in JPA? (To allow user to change password)

mike__rainvilleNov 10 2014 — edited Nov 20 2014

Is it possible to let a user change their own password  in Eclipse Persistence Services - 2.5.2.v20140319, Java 6u45 (also 7u72)?

When I run it I get

ORA-01935: missing user or role name

Password for user: XXXXXXXX was not changed. (i.e. at the time of the exception, username has the right value )

This JDBC code is being used via JPA 2.1 using:

jdbcConnection = entityManager.unwrap(java.sql.Connection.class);

public PreparedStatement changeDatabasePassword( java.sql.Connection jdbcConnection ) throws SQLException  {

  

    String alterUserSQL = "ALTER USER ? IDENTIFIED BY ? REPLACE ?";

    PreparedStatement  preparedStatement = null;;

  

    preparedStatement = jdbcConnection.prepareStatement( alterUserSQL );

      

    preparedStatement.setString( 1, this.username.getText() );

    preparedStatement.setString( 2, new String( this.newPassword.getPassword() ) );

    preparedStatement.setString( 3, new String( this.password.getPassword() ) );

  

    return  preparedStatement;

    } // end method setStatusMessageText(

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 8 2014
Added on Nov 10 2014
1 comment
660 views