连接Java和Teradata:用户标识、密码或帐户无效。

时间:2021-07-23 02:53:00

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异常。我也检查了我的用户名和密码是否正确。


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

这是我得到的结果

连接Java和Teradata:用户标识、密码或帐户无效。

What is Bad Password? I used SQL Assistant with this very password and it works great. Why cannot i connect with Java?

不好的密码是什么?我用SQL Assistant设置了这个密码,效果很好。为什么我不能连接Java?

5 个解决方案

#1


2  

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。通过控制台登录teradata中的logonoff表,以确保您的用户没有被锁定,或者了解您的驱动程序是否正在访问teradata。

select * 
  from dbc.logonoff 
 where logdate >= date '2013-10-31'

#2


6  

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.

在DBC中不会捕获LDAP身份验证失败。登录作为一个糟糕的密码事件,因为身份验证在数据库中不发生。

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.

通常,您正在接收的错误消息,UserId、密码或帐户无效。,表示正在锁定数据库的用户帐户。

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.

maxlogontryts_将告诉您,在锁定帐户之前,您可以尝试使用数据库身份验证(TD2)登录多少次。

A couple of things I would suggest:

我有几点建议:

  1. Remove whitespace between the parameters of connectString
  2. 删除connectString参数之间的空格
  3. Put the User and Password parameters in the connectString
  4. 将用户和密码参数放在connectString中
  5. 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 added DefaultAccount).
  6. 使用上面的原始代码修改connectString以添加:,ACCOUNT=$AMRWRW&DrT&r,它应该与上面的响应中查询返回的内容相匹配(我添加了DefaultAccount)。

EDIT: 11/12/13 May 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密码登录的显式权限,导致错误消息“UserId、密码或帐户无效”。前几天,我使用一个特权帐户收到了这个消息,但没有将登录机制从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.

它可能不会返回任何东西,这是可以的。这仅仅意味着您没有从系统上的任何主机上显式地授予或撤消登录该userid的能力。

EDIT: 05/22/18 The “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当提供的密码与存储在目录服务器上的密码不匹配时,外部认证用户的“坏密码”事件可能会出现在事件日志中。在某些场景中,可以通过使用来自PDN的ldapsearch直接向LDAP目录提交查询来验证这一点。您可以在安全管理手册中找到关于使用此命令的更多细节。我发现,这是为了对无法对目录进行身份验证的用户帐户的子集进行分类。我觉得用更多的细节来更新这个答案是合适的,因为我在上面的陈述不是100%准确的。

#3


2  

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.

原因:指定了LOGMECH=LDAP,并且在LOGDATA和作为独立连接参数提供的用户名/密码凭据都是冗余的。

Solution: Identify LDAP users via LOGDATA, or via separate username/password parameters, but not both simultaneously.

解决方案:通过LOGDATA或单独的用户名/密码参数识别LDAP用户,但不能同时识别和识别。

So, you should check this case. May be you can get connection without user/password

所以,你应该检查这个例子。您是否可以在没有用户/密码的情况下获得连接

#4


1  

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驱动程序。

#5


0  

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援助编辑器用相同的用户名和密码连接到DB。

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";

字符串connurl = " jdbc:teradata:/ / = xx,xx /数据库用户= xx,密码= xx,tmode = ANSI,charset = UTF8,LOGMECH = LDAP”;

#1


2  

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。通过控制台登录teradata中的logonoff表,以确保您的用户没有被锁定,或者了解您的驱动程序是否正在访问teradata。

select * 
  from dbc.logonoff 
 where logdate >= date '2013-10-31'

#2


6  

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.

在DBC中不会捕获LDAP身份验证失败。登录作为一个糟糕的密码事件,因为身份验证在数据库中不发生。

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.

通常,您正在接收的错误消息,UserId、密码或帐户无效。,表示正在锁定数据库的用户帐户。

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.

maxlogontryts_将告诉您,在锁定帐户之前,您可以尝试使用数据库身份验证(TD2)登录多少次。

A couple of things I would suggest:

我有几点建议:

  1. Remove whitespace between the parameters of connectString
  2. 删除connectString参数之间的空格
  3. Put the User and Password parameters in the connectString
  4. 将用户和密码参数放在connectString中
  5. 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 added DefaultAccount).
  6. 使用上面的原始代码修改connectString以添加:,ACCOUNT=$AMRWRW&DrT&r,它应该与上面的响应中查询返回的内容相匹配(我添加了DefaultAccount)。

EDIT: 11/12/13 May 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密码登录的显式权限,导致错误消息“UserId、密码或帐户无效”。前几天,我使用一个特权帐户收到了这个消息,但没有将登录机制从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.

它可能不会返回任何东西,这是可以的。这仅仅意味着您没有从系统上的任何主机上显式地授予或撤消登录该userid的能力。

EDIT: 05/22/18 The “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当提供的密码与存储在目录服务器上的密码不匹配时,外部认证用户的“坏密码”事件可能会出现在事件日志中。在某些场景中,可以通过使用来自PDN的ldapsearch直接向LDAP目录提交查询来验证这一点。您可以在安全管理手册中找到关于使用此命令的更多细节。我发现,这是为了对无法对目录进行身份验证的用户帐户的子集进行分类。我觉得用更多的细节来更新这个答案是合适的,因为我在上面的陈述不是100%准确的。

#3


2  

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.

原因:指定了LOGMECH=LDAP,并且在LOGDATA和作为独立连接参数提供的用户名/密码凭据都是冗余的。

Solution: Identify LDAP users via LOGDATA, or via separate username/password parameters, but not both simultaneously.

解决方案:通过LOGDATA或单独的用户名/密码参数识别LDAP用户,但不能同时识别和识别。

So, you should check this case. May be you can get connection without user/password

所以,你应该检查这个例子。您是否可以在没有用户/密码的情况下获得连接

#4


1  

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驱动程序。

#5


0  

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援助编辑器用相同的用户名和密码连接到DB。

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";

字符串connurl = " jdbc:teradata:/ / = xx,xx /数据库用户= xx,密码= xx,tmode = ANSI,charset = UTF8,LOGMECH = LDAP”;