连接 Java 和 Teradata:用户 ID、密码或帐户无效
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19776230/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Connecting Java and Teradata: The UserId, Password or Account is invalid
提问by Borat Sagddiev
I have been trying to connect to Teradata
我一直在尝试连接到 Teradata
Class.forName("com.teradata.jdbc.TeraDriver");
String connectionString = "jdbc:teradata://xxx.xxxxxx.com/database=xxxxxx, tmode=ANSI, charset=UTF8";
String user = "Rocket512";
String password = "aui8mn5";
Connection conn = DriverManager.getConnection(connectionString, user, password);
Got the following
得到以下
Exception in thread "main" com.teradata.jdbc.jdbc_4.util.JDBCException: [Teradata Database]
[TeraJDBC 14.10.00.17] [Error 8017] [SQLState 28000] The UserId, Password or Account is invalid.
at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDatabaseSQLException(ErrorFactory.java:300)
at com.teradata.jdbc.jdbc.GenericLogonController.run(GenericLogonController.java:666)
at com.teradata.jdbc.jdbc_4.TDSession.<init>(TDSession.java:216)
I know that the host is specified correctly since i did not get UnknownHost Exception.
Also I have double checked my userid and password are correct.
我知道主机是正确指定的,因为我没有得到UnknownHost Exception.
我还仔细检查了我的用户名和密码是否正确。
I ran query suggested by @beni23 (thank you)
我运行了@beni23 建议的查询(谢谢)
select *
from dbc.logonoff
where logdate >= date '2013-10-31'
Here is the result that I got
这是我得到的结果
What is Bad Password
? I used SQL Assistant with this very password and it works great. Why cannot i connect with Java?
什么是Bad Password
?我用这个密码使用了 SQL 助手,效果很好。为什么我无法连接Java?
采纳答案by beny23
The following might not give you a solution, but might point you in the right direction. I think you'll want to check the dbc.logonoff
table in teradata through a console to make sure that your user is not locked or get an idea whether your driver is hitting teradata.
以下内容可能不会为您提供解决方案,但可能会为您指明正确的方向。我认为您需要dbc.logonoff
通过控制台检查teradata 中的表,以确保您的用户没有被锁定或了解您的驱动程序是否正在访问 teradata。
select *
from dbc.logonoff
where logdate >= date '2013-10-31'
回答by Paul Whelan
Perhaps you might have more luck with:
也许你可能有更多的运气:
String driver = "com.teradata.jdbc.TeraDriver";
String conUrl="jdbc:teradata://xxx.xxxxxx.com/database=xxxxxx,USER=Rocket512,PASSWORD=aui8mn5,tmode=ANSI,charset=UTF8";
Class.forName(driver);
Connection dbConn = DriverManager.getConnection(conUrl);
If that doesn't work make sure to use the latest jdbc driver.
如果这不起作用,请确保使用最新的 jdbc 驱动程序。
回答by Ilya
Reading this article Troubleshooting Security: The UserId, Password or Account is invalid.we can see the typical reason of this error.
阅读这篇文章安全性故障排除:用户 ID、密码或帐户无效。我们可以看到这个错误的典型原因。
Cause:LOGMECH=LDAP is specified, and the username/password credentials are redundantly provided in the both LOGDATA and as separate connection parameters.
Solution:Identify LDAP users via LOGDATA, or via separate username/password parameters, but not both simultaneously.
原因:指定了 LOGMECH=LDAP,并且在 LOGDATA 和单独的连接参数中冗余提供了用户名/密码凭据。
解决方案:通过 LOGDATA 或通过单独的用户名/密码参数识别 LDAP 用户,但不能同时使用。
So, you should check this case. May be you can get connection without user/password
所以,你应该检查这个案例。也许你可以在没有用户/密码的情况下获得连接
回答by Rob Paller
LDAP Authentication failures will not be captured in DBC.LogOnOff
as a Bad Password
event because the authentication doesn't take place on the database.
LDAP 身份验证失败不会DBC.LogOnOff
作为Bad Password
事件捕获,因为身份验证不在数据库上进行。
Typically the error message you are receiving, The UserId, Password or Account is invalid.
, is indicative of the user account being locked on the database.
通常,您收到的错误消息The UserId, Password or Account is invalid.
表明用户帐户被锁定在数据库上。
SELECT U.UserName
, U.ProfileName
, U.DefaultAccount
, COALESCE(P.MAXLOGONATTEMPTS, S.MAXLOGONATTEMPTS) AS MaxLogonAttempts_
, U.LockedCount
, U.LockedDate
FROM dbc.UsersV U
LEFT JOIN
dbc.ProfileInfoV P
ON P.ProfileName = U.ProfileName
CROSS JOIN
dbc.SecurityDefaults S
WHERE UserName = 'Rocket512';
If LockedCount
is not 0
than a failed logon attempt has occurred since the last successful logon to the database.
如果LockedCount
不0
超过自上一次成功登录到数据库时发生失败的登录尝试。
If LockedDate
is not NULL
it represents the date which the account was last locked.
如果LockedDate
不是,NULL
则表示上次锁定帐户的日期。
MaxLogonAttempts_
will tell you how many times you can attempt to logon using database authentication (TD2) before the account is locked.
MaxLogonAttempts_
将告诉您在帐户被锁定之前可以尝试使用数据库身份验证 (TD2) 登录的次数。
A couple of things I would suggest:
我建议几点:
- Remove whitespace between the parameters of
connectString
- Put the User and Password parameters in the
connectString
- Using original code above modify the
connectString
to add:,ACCOUNT=$AMRWRW&DrT&r
which should match what is returned by the query in my response above (I have addedDefaultAccount
).
- 删除参数之间的空格
connectString
- 将 User 和 Password 参数放在
connectString
- 使用上面的原始代码修改
connectString
to add:,ACCOUNT=$AMRWRW&DrT&r
这应该与我上面的响应中的查询返回的内容相匹配(我已经添加了DefaultAccount
)。
EDIT: 11/12/13May I suggest you download Teradata Studio Express and attempt to make a connection to the same Teradata system using JDBC much like you are here in your code. This may help shed light on the parameters you need to specify in your connection string in order to make the connection successful. You should be able to setup your connection parameters in Teradata Studio Express the same as you have here in your code and see if it works.
编辑:11/12/13我建议您下载 Teradata Studio Express 并尝试使用 JDBC 连接到同一个 Teradata 系统,就像您在代码中一样。这可能有助于阐明您需要在连接字符串中指定的参数,以使连接成功。您应该能够在 Teradata Studio Express 中设置您的连接参数,就像您在代码中设置的一样,看看它是否有效。
Using LDAP as the logon mechanism for a user that has not been granted the explicit right to logon with a NULL password has resulted in the error message `The UserId, Password or Account is invalid.'. I received this the other day using a privileged account without changing my logon mechanism from LDAP to TD2.
使用 LDAP 作为尚未被授予使用 NULL 密码登录的显式权限的用户的登录机制会导致错误消息“用户 ID、密码或帐户无效。”。前几天我使用特权帐户收到了这个,没有将我的登录机制从 LDAP 更改为 TD2。
What does the following SQL return?
以下 SQL 返回什么?
SELECT *
FROM DBC.LogonRulesV
WHERE UserName = 'Rocket512';
It may not return anything, which is okay. This simply means you ability to logon with that userid from any host on the system has not been explicitly granted or revoked.
它可能不会返回任何东西,这没关系。这只是意味着您从系统上的任何主机使用该用户 ID 登录的能力尚未被明确授予或撤销。
EDIT: 05/22/18The “Bad Password” event for an externally authenticated user may will appear in the event log when the provided password and the what is stored on the directory server do not match. In certain scenarios you can verify this by using ldapsearch
from the PDN to submit an inquiry directly to the LDAP directory. You can find more details about using this command in the Security Administration manual. I've discovered this trying to triage a problem with a subset of user accounts that fail to authenticate to the directory. I felt it would be appropriate to update this answer with more details as my lead in statement at the top is not 100% accurate.
编辑:05/22/18当提供的密码与目录服务器上存储的内容不匹配时,外部身份验证用户的“密码错误”事件可能会出现在事件日志中。在某些情况下,您可以通过使用ldapsearch
从 PDN 直接向 LDAP 目录提交查询来验证这一点。您可以在安全管理手册中找到有关使用此命令的更多详细信息。我发现这试图对无法对目录进行身份验证的用户帐户子集进行分类。我觉得用更多细节更新这个答案是合适的,因为我在顶部的先导声明不是 100% 准确的。
回答by Kishore Dubey
I had similar error and followed all the suggestions given in here. My account was not locked and I was able to connect to the DB with the same username and password, via SQL assistance editor.
我有类似的错误,并遵循了此处给出的所有建议。我的帐户没有被锁定,我能够通过 SQL 辅助编辑器使用相同的用户名和密码连接到数据库。
The solution worked for me was adding following line in the connection string: LOGMECH=LDAP.
对我有用的解决方案是在连接字符串中添加以下行:LOGMECH=LDAP。
You need to know the logon mechanism for your Teradata, or you can reach out to your DBA team, as I did. So your connection string will look something like this:
您需要了解 Teradata 的登录机制,或者可以像我一样联系您的 DBA 团队。所以你的连接字符串看起来像这样:
String connurl="jdbc:teradata://xx/database=xx,USER=xx,PASSWORD=xx,tmode=ANSI,charset=UTF8,LOGMECH=LDAP";
String connurl="jdbc:teradata://xx/database=xx,USER=xx,PASSWORD=xx,tmode=ANSI,charset=UTF8,LOGMECH=LDAP";