简体   繁体   中英

Oracle 11g r2 ORA-01017: invalid username/password; logon denied when connecting via JDBC driver

I'm not an Oracle expert nor a Database Administrator. But we have this Java program that we created and it used to connect to an Oracle 9i database (Windows environment), using the OCI driver.

But when we migrated to Oracle 11g r2 (Linux environment), we got this error when we tried to run the tool:

ORA-01017: invalid username/password; logon denied

I've tried a lot of possible codes to connect to the database (specifying host and port instead of just SID/service name, setting Properties object, using OracleDataSource, switching from OCI driver to thin driver, checking REMOTE_LOGIN_PASSWORDFILE, etc.) But still the same error.

Do you think this is a driver issue? Do we need to configure something in the database? By the way, these are the versions: JDBC => 11.2.0.3.0 Oracle DB => 11.2.0.4.0

In addition, I can't connect to sqlplus if I indicate the connect string:

sqlplus user@ORCL as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Apr 17 11:27:45 2015

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Enter password: 

ERROR: ORA-01017: invalid username/password; logon denied

However, I can connect without indicating the connect string. The ORACLE_SID is set upon logging in to the server.

sqlplus user as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Apr 17 11:28:06 2015

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Enter password:

Connected to: Oracle Database 11g Enterprise Edition Release
11.2.0.4.0 - 64bit Production

Is there a missing configuration that we should have set? Thanks in advance.

This is most likely happening because the Database server is using a strong verifier for this user and your client (either sqlplus or JDBC) doesn't support this password verifier. You can either upgrade sqlplus and JDBC thin or make the server generate both strong and weak password verifiers so that old clients can still connect. To do so please follow this procedure:

In sqlnet.ora on the server set the logon version to 10:

allowed_logon_version=10

And regenerate the user's password (to re-generate the verifiers):

ALTER USER user IDENFIFIED BY "newpassword";

ORA-01017: invalid username/password; logon denied

As others have said, this error message says it all. You have not specified a valid username/password combination. It's that simple. There are some Oracle error messages that can be unclear, but this is not one of those.

Specify the username and password of an Oracle user in the database and your login should succeed.

I'm using a user that accepts any password as long as I'm connected as a root user.

You're using SQL*Plus while logged on to the same machine as the database is running, and you are logged in to Linux as a user that has membership of the dba group. In this situation, you can log on no matter what username or password you specify. In fact, I've just tried to run

sqlplus blah/blah as sysdba

to connect to my Oracle 11g XE database, and this connected fine, despite the fact that my database has no blah user.

Note also that if you do connect this way, you will be connected as the Oracle SYS user, a fact you can confirm by running the query select user from dual; .

Please don't assume that you can connect to Oracle using your OS user credentials. You may be able to log in to SQL*Plus with your OS username and no password, but that's only because in your situation SQL*Plus lets you in regardless of your credentials. Oracle users are separate to OS users. Just because you can log in to your OS using a given username and password doesn't mean you can log in to Oracle with the same credentials.

Presumably there was an Oracle user in your 9i database that your application connected as? Does a similar Oracle user exist in your 11g database? Have you tried connecting as this user? Have you tried resetting its password? (Connect as SYS and then enter alter user username identified by "newpassword"; .)

Once you can get a login to SQL*Plus using a connection string to succeed, you can then look at using the same username, password and connection string in JDBC.

My guess would be that you have a case problem in your password. oracle changed how passwords were treated in 11g, they are now case sensitive where in version 9i they were not.

May be one of the following helps:

  1. Check and choose the right connection string style, base on the DB configuration:

    From the ORACLE thin-style syntax description :

     Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:scott/tiger@//myhost:1521/myservicename");

    Connect with SID (from the ORACLE documentation ):

     Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@myhost:1521:orcl", "scott", "tiger");
  2. Check if you added "as sysdba" to the user name (check FAQ here )

  3. Rather unlikely but possible: check if your user name and/or password is case sensitive. In this case they are enclose them in "

您必须在程序中检查您的数据库的用户名和密码以及连接字符串,更改 CASE 会导致此错误

For me I installed oracle client 11g R2 and oracle database 12.2 version then created the tnsnames.ora by using NETCA under BIN folder in client PC , then i added the following lines to the file SQLNET.ora in the database server :

SQLNET.ALLOWED_LOGON_VERSION_CLIENT = 8
SQLNET.ALLOWED_LOGON_VERSION_SERVER = 8

After that i can login by using system user only , and when i tried to login with any other user i got error `

ORA-01017: invalid username/password; logon denied`

Finally i solved it by changing the password for other users from system user in client side SQL . thats the way i solved my error .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM