[英]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.我不是 Oracle 专家,也不是数据库管理员。 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.
但是我们有我们创建的这个 Java 程序,它使用 OCI 驱动程序连接到 Oracle 9i 数据库(Windows 环境)。
But when we migrated to Oracle 11g r2 (Linux environment), we got this error when we tried to run the tool:但是当我们迁移到 Oracle 11g r2(Linux 环境)时,我们尝试运行该工具时出现此错误:
ORA-01017: invalid username/password;
ORA-01017: 无效的用户名/密码; 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.我已经尝试了很多可能的代码来连接到数据库(指定主机和端口,而不仅仅是 SID/服务名称、设置属性对象、使用 OracleDataSource、从 OCI 驱动程序切换到瘦驱动程序、检查 REMOTE_LOGIN_PASSWORDFILE 等)但仍然同样的错误。
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
顺便说一下,这些是版本: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:
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.
ORACLE_SID 在登录服务器时设置。
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.这很可能发生,因为数据库服务器正在为此用户使用强大的验证程序,而您的客户端(sqlplus 或 JDBC)不支持此密码验证程序。 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.
您可以升级 sqlplus 和 JDBC 瘦身,也可以让服务器生成强弱密码验证程序,以便旧客户端仍然可以连接。 To do so please follow this procedure:
为此,请按照以下步骤操作:
In sqlnet.ora on the server set the logon version to 10:在服务器上的 sqlnet.ora 中,将登录版本设置为 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;
ORA-01017: 无效的用户名/密码; 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.
有一些 Oracle 错误消息可能不清楚,但这不是其中之一。
Specify the username and password of an Oracle user in the database and your login should succeed.在数据库中指定 Oracle 用户的用户名和密码,您的登录应该会成功。
I'm using a user that accepts any password as long as I'm connected as a root user.
只要我以 root 用户身份连接,我使用的用户就可以接受任何密码。
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.您在登录到运行数据库的同一台机器时使用 SQL*Plus,并且您以具有
dba
组成员身份的用户身份登录到 Linux。 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.连接到我的 Oracle 11g XE 数据库,并且连接正常,尽管我的数据库没有
blah
用户。
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;
另请注意,如果您以这种方式连接,您将作为 Oracle
SYS
用户连接,您可以通过运行查询select user from dual;
来确认这一事实select user from dual;
. .
Please don't assume that you can connect to Oracle using your OS user credentials.请不要假设您可以使用您的操作系统用户凭据连接到 Oracle。 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.
您也许可以使用您的操作系统用户名而不使用密码登录 SQL*Plus,但这只是因为在您的情况下 SQL*Plus 允许您登录,而不管您的凭据如何。 Oracle users are separate to OS users.
Oracle 用户独立于 OS 用户。 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.
仅仅因为您可以使用给定的用户名和密码登录操作系统并不意味着您可以使用相同的凭据登录 Oracle。
Presumably there was an Oracle user in your 9i database that your application connected as?想必您的应用程序连接的 9i 数据库中有一个 Oracle 用户? Does a similar Oracle user exist in your 11g database?
您的 11g 数据库中是否存在类似的 Oracle 用户? 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";
.) (以
SYS
alter user username identified by "newpassword";
连接,然后输入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.一旦您可以使用连接字符串成功登录到 SQL*Plus,您就可以查看在 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.
oracle 更改了 11g 中密码的处理方式,现在它们区分大小写,而在 9i 版本中则不区分大小写。
May be one of the following helps:可能是以下帮助之一:
Check and choose the right connection string style, base on the DB configuration:根据数据库配置检查并选择正确的连接字符串样式:
From the ORACLE thin-style syntax description :来自 ORACLE 瘦风格语法描述:
Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:scott/tiger@//myhost:1521/myservicename");
Connect with SID (from the ORACLE documentation ):与 SID 连接(来自 ORACLE 文档):
Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@myhost:1521:orcl", "scott", "tiger");
Check if you added "as sysdba"
to the user name (check FAQ here )检查您是否在用户名中添加了
"as sysdba"
( 在此处查看常见问题解答)
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 :对我来说,我安装了 oracle 客户端 11g R2 和 oracle 数据库 12.2 版本,然后使用客户端 PC 中 BIN 文件夹下的 NETCA 创建了 tnsnames.ora,然后我将以下几行添加到数据库服务器中的文件 SQLNET.ora 中:
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 .最后我通过在客户端 SQL 中从系统用户更改其他用户的密码来解决它。 thats the way i solved my error .
这就是我解决错误的方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.