3 Replies Latest reply: Dec 6, 2012 1:38 AM by 977834 RSS

    Java: Change password using OCI

    977834

      Hi

      I try to change an expired password from Java. That's not possible with thin client, but should work with "thick", i.e. OCI. So far, I have this:

      1. Properties props = new Properties();
      2. props.put("user", "my username");
      3. props.put("password", "my old password");
      4. props.put("OCINewPassword", "my new password");
      5. String ociUrl = "jdbc:oracle:oci:@...";
      6. Connection connection = DriverManager.getConnection(ociUrl, props);

      But I'm getting a "java.sql.SQLException: ORA-01017: invalid username/password; logon denied".

      The client's OS is Windows 7. Oracle instant client (11.2) is installed and on the Path. The database is Oracle 11.2.

      And "my old password" is correct. If I comment out line 4, connecting works. If I use :thin: driver, connecting works also, but the property "OCINewPassword" is then being ignored.

      Any help or hint is much appreciated.

      Thanks.

      Stefan

      P.S. I posted the question first in the "call interface" forum, but I think this one suits better.

        • 1. Re: Java: Change password using OCI
          rp0428
          >
          I try to change an expired password from Java. That's not possible with thin client, but should work with "thick", i.e. OCI. So far, I have this:

          1. Properties props = new Properties();
          2. props.put("user", "my username");
          3. props.put("password", "my old password");
          4. props.put("OCINewPassword", "my new password");
          5. String ociUrl = "jdbc:oracle:oci:@...";
          6. Connection connection = DriverManager.getConnection(ociUrl, props);

          But I'm getting a "java.sql.SQLException: ORA-01017: invalid username/password; logon denied".

          The client's OS is Windows 7. Oracle instant client (11.2) is installed and on the Path. The database is Oracle 11.2.

          And "my old password" is correct. If I comment out line 4, connecting works. If I use :thin: driver, connecting works also, but the property "OCINewPassword" is then being ignored.
          >
          You don't say which OJDBC jar file (name and version) you are using and that is critical for OCI.

          Works for me using Oracle Client - see my reply in the thread
          Re: Replacing old OCINewPassword method

          More importantly see Joe Weinstein's reply right below mine:
          >
          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.
          >
          And there is more information and examples in the JDBC Dev Guide
          http://docs.oracle.com/cd/E11882_01/java.112/e16548/instclnt.htm#CHDCJEDD
          • 2. Re: Java: Change password using OCI
            977834
            Thanks for the quick answer.

            It's ojdbc6.jar, Implementation-Version: 11.2.0.3.0. I took it from the download of instant client, so the version of jar an dlls should match. I read the thread you mentioned (that's where my code is from ;-)).

            I'm aware that for "normal use" thin client is the way to go and I need th OCI client only for the specific purpose "password change".

            It's good to hear, that in your case it works. So I see a chance bringig it up and running. Still, my problem remains ;-).

            I'll consume http://docs.oracle.com/cd/E11882_01/java.112/e16548/instclnt.htm#CHDCJEDD again, see if I find something.


            Note:
            I tried also OracleOCIConnectionPool, passing the new password using as a property:

            Properties props = new Properties();
            props.put("OCINewPassword", "my new password");
            OracleOCIConnectionPool pool = new OracleOCIConnectionPool("my user", "my password", "the url", props);

            But away from the fact that it's useless to use a pool in this case, I got here another exception: java.sql.SQLException: Ungültige Connection Pool-Konfiguratin des JDBC-OCI-Treibers angegeben (which means "invalid connection pool configuration of jdbc-oci-driver").
            • 3. Re: Java: Change password using OCI
              977834
              Well, I finally succeeded. Phew!

              There is not only a rigid one-to-one relationship between a single given driver jar version and a single version of the OCI client libraries (Joe Weinstein) but apparently also between the thin client's and the database's version. Our database is 11.2.0.2 and I was using instant client 11.2.0.3. Switched to instant client 11.2.0.2 and - guess what? It works.

              Thanks for the hints!