This discussion is archived
5 Replies Latest reply: Oct 2, 2012 6:37 AM by 944844 RSS

Replacing old OCINewPassword method

944844 Newbie
Currently Being Moderated
I'm upgrading a legacy app to run with the latest version of Weblogic and oracle database using the THIN driver.

It contained a password reset method that apparently is no longer supported. Can someone point me to the proper method for resetting a password during the Oracle reset grace period with JDBC?

(This question was previously asked but not answered in another person's thread: OCINewPassword property

Here is my code:

Properties ociProps = new Properties();
String url = "jdbc:oracle:oci8:@"+ SID;

ociProps.put ("user",user);
ociProps.put ("password", password);
ociProps.put ("OCINewPassword", newpassword);

conn = DriverManager.getConnection (url, ociProps);

When the getConnection is executed, this sets the new password.

Edited by: user11033035 on Sep 28, 2012 1:22 PM
  • 1. Re: Replacing old OCINewPassword method
    rp0428 Guru
    Currently Being Moderated
    >
    I'm upgrading a legacy app to run with the latest version of Weblogic and oracle database using the THIN driver.

    It contained a password reset method that apparently is no longer supported.
    >
    That is incorrect - that password reset still works. I just tested it on 11g rel 2 using the ojdbc6.jar file and the code that you posted with obvious changes
            Properties ociProps = new Properties();
            String url = "jdbc:oracle:oci8:@"+ "myDBName";
            ociProps.put ("user","scott");
            ociProps.put ("password", "tiger");
            ociProps.put ("OCINewPassword", "tigernew");
            con = DriverManager.getConnection (url, ociProps);
    After running the code I could no longer connect using the 'tiger' password but 'tigernew' worked just fine.

    I noticed that in your post you said 'using the THIN driver'. Well, as the name of the property (OCINewPassword) suggests that functionality is only (and always was) supported using the OCI driver; it will not work with the thin driver.
  • 2. Re: Replacing old OCINewPassword method
    944844 Newbie
    Currently Being Moderated
    Thanks for testing that rp0428. I should clarify that our server environment no longer has an OCI datasource available, so we have to use thin datasource.

    For some reason this OCI- specific code had actually been working this way, until the JDBC driver was updated to 11.2.0.3.0. Then we started getting an Oracle error in the stack trace:

    java.lang.UnsatisfiedLinkError: oracle.jdbc.driver.T2CConnection.getLibraryVersionNumber()I
    at oracle.jdbc.driver.T2CConnection.getLibraryVersionNumber(Native Method)
    at oracle.jdbc.driver.T2CConnection$1.run(T2CConnection.java:3552)
    at java.security.AccessController.doPrivileged(Native Method)
    at oracle.jdbc.driver.T2CConnection.loadNativeLibrary(T2CConnection.java:3547)
    at oracle.jdbc.driver.T2CConnection.logon(T2CConnection.java:266)
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:546)
    at oracle.jdbc.driver.T2CConnection.<init>(T2CConnection.java:162)

    So with that....

    What is the recommended method for resetting an Oracle password inside the application, using JDBC? This OCI method was able to automatically handle an account that EXPIRED.
  • 3. Re: Replacing old OCINewPassword method
    Joe Weinstein Expert
    Currently Being Moderated
    The stackt race you show indicates that you are still trying to use the OCI driver.
    To be clearer, there is only one java-level driver from Oracle, and depending on
    the URL you give it, it will connect to the DBMS in the all-java way, eg:

    "jdbc:oracle:thin:..."

    or will use the available OCI libraries to do the connectivity:

    "jdbc:oracle:oci:..."

    Your stack trace shows me dirver-internal classes that would not be used
    if you were trying to connect in the thin mode, so you should check all your
    driver URLs and change them according to the driver docs to connect in the
    thin mode.

    Note that in the all-java mode, the driver is freely updateable and needs nothing
    else from the environment to work. However, in the OCI mode there is a rigid
    one-to-one relationship between a single given driver jar version and a single
    version of the OCI client libraries. If you update one without the other, you
    will get inscrutable failures. This is all the more reason to get to the all-java mode.
    HTH,
    Joe
  • 4. Re: Replacing old OCINewPassword method
    rp0428 Guru
    Currently Being Moderated
    >
    For some reason this OCI- specific code had actually been working this way, until the JDBC driver was updated to 11.2.0.3.0. Then we started getting an Oracle error in the stack trace:

    java.lang.UnsatisfiedLinkError: oracle.jdbc.driver.T2CConnection.getLibraryVersionNumber()I
    >
    It is more likely that you no longer have the OCI client software available on the machine doing the connection.
    That error message means the ocijdbc11.dll file cannot be found and that dll is part of the OCI client.

    As I stated above I successfully tested the ojdbc6.jar file used for 11g
    >
    What is the recommended method for resetting an Oracle password inside the application, using JDBC? This OCI method was able to automatically handle an account that EXPIRED.
    >
    The same way a password is reset when JDBC is not used. A user with DBA privileges needs to issue
    ALTER USER userWhoExpired IDENTIFIED BY newPassword;
    So using JDBC you need to establish a connection as a DBA-privileged user and execute the above query.
  • 5. Re: Replacing old OCINewPassword method
    944844 Newbie
    Currently Being Moderated
    Marking this answered. Looks like I need to use the thin driver.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points