JDBC driver NullPointerException TdgssConfigApi.GetMechanisms(Unknown Source)

Connectivity
Enthusiast

JDBC driver NullPointerException TdgssConfigApi.GetMechanisms(Unknown Source)

I  am trying to use the JDBC driver (version 16.00.00.24) to connect from a linux host to our teradata system.

But when excecuting the java programm (test) i get the following:

Exception in thread "main" java.lang.ExceptionInInitializerError
        at com.teradata.jdbc.jdbc.GenericTeraEncrypt.getGSSM(GenericTeraEncrypt.java:577)
        at com.teradata.jdbc.jdbc.GenericTeraEncrypt.<init>(GenericTeraEncrypt.java:116)
        at com.teradata.jdbc.jdbc.GenericTeradataConnection.<init>(GenericTeradataConnection.java:104)
        at com.teradata.jdbc.jdbc_4.TDSession.<init>(TDSession.java:185)
        at com.teradata.jdbc.jdk6.JDK6_SQL_Connection.<init>(JDK6_SQL_Connection.java:36)
        at com.teradata.jdbc.jdk6.JDK6ConnectionFactory.constructSQLConnection(JDK6ConnectionFactory.java:25)
        at com.teradata.jdbc.jdbc.ConnectionFactory.createConnection(ConnectionFactory.java:179)
        at com.teradata.jdbc.jdbc.ConnectionFactory.createConnection(ConnectionFactory.java:169)
        at com.teradata.jdbc.TeraDriver.doConnect(TeraDriver.java:235)
        at com.teradata.jdbc.TeraDriver.connect(TeraDriver.java:161)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:247)
        at test.main(test.java:26)
Caused by: java.lang.NullPointerException
        at com.teradata.tdgss.jtdgss.TdgssConfigApi.GetMechanisms(Unknown Source)
        at com.teradata.tdgss.jtdgss.TdgssManager.<init>(Unknown Source)
        at com.teradata.tdgss.jtdgss.TdgssManager.<clinit>(Unknown Source)
        ... 13 more

 

The linux host is on Java version:

openjdk version "1.8.0_121"
OpenJDK Runtime Environment (build 1.8.0_121-b13)
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)

 

My run-file looks like:

export CLASSPATH="$CLASSPATH:/home/BELASTINGDIENST/zwanl02/jdbc/terajdbc4.jar:/home/BELASTINGDIENST/zwanl02/jdbc/tdgssconfig.jar"
java test <userid> <password>

 

Does anyone have an idea where the (Unkown Source ) is coming from ?

 

The connectstring in my Java programm looks like:

// Creation of URL to be passed to the JDBC driver.

String url = "jdbc:teradata://10.224.51.234/TMODE=TERA,CHARSET=UTF16";

// Creating a connection object
            Connection con = DriverManager.getConnection(url, user, password);

 

7 REPLIES
Teradata Employee

Re: JDBC driver NullPointerException TdgssConfigApi.GetMechanisms(Unknown Source)

This topic is discussed in the Troubleshooting chapter of the Teradata JDBC Driver User Guide:

http://developer.teradata.com/doc/connectivity/jdbc/reference/current/jdbcug_chapter_5.html#CHDIJJJH

 

The problem may be due to the classpath not being set, or the classpath being set incorrectly, such that tdgssconfig.jar cannot be found.

Enthusiast

Re: JDBC driver NullPointerException TdgssConfigApi.GetMechanisms(Unknown Source)

Tom, thanks for the answer.

The article i already read.

After some trial and error if found out that the error was (as you mentioned) is in the classpath.

When i added the : after the last statement the error was gone.

 

But ....

Then the next error occurs:

*** SQLException caught ***
 Error code: 8017
 SQL State: 28000
 Message: [Teradata Database] [TeraJDBC 16.00.00.24] [Error 8017] [SQLState 28000] The UserId, Password or Account is invalid.

 

Apr 18 07:52:51 NLTAX03-1-10 Teradata[24679]: Logon Failed
Apr 18 07:52:51 NLTAX03-1-10 Teradata[24679]:Session: 5252539 UserName: Failed authentication User Account:  Logicalhostid: 1
Apr 18 07:52:51 NLTAX03-1-10 Teradata[24679]:IFPNo: 30718 Code: 3003 Eventtype: Logon failed
Apr 18 07:52:51 NLTAX03-1-10 Teradata[24679]:Msg: gtwaction.cpp @ 6002 : Invalid password.

 

So the correct responce would be to provide the correct password, but i already provide the correct password.

I even set the password in Teradata to match the one from the script with copy and past, but the invalid password remains.

 

Can it be that the password is being altered (encrypted) during the call?

 

regards,

Laurens

Teradata Employee

Re: JDBC driver NullPointerException TdgssConfigApi.GetMechanisms(Unknown Source)

Yes, the password is encrypted.

No, the password is not altered.

 

The most likely reason for the error is that you provided the incorrect password.

 

Another possible reason is that you specified the wrong logon mechanism, or you failed to specify the necessary logon mechanism. You can specify the logon mechanism with the LOGMECH connection parameter. If you omit the LOGMECH connection parameter, then the logon mechanism defaults to TD2.

 

For example, if the password you specified is an LDAP password, then you must also specify LOGMECH=LDAP.

Teradata Employee

Re: JDBC driver NullPointerException TdgssConfigApi.GetMechanisms(Unknown Source)

Does your password contain special characters that need to be quoted / escaped in order to be passed into your program from the shell?

Enthusiast

Re: JDBC driver NullPointerException TdgssConfigApi.GetMechanisms(Unknown Source)

Here is a brief example of my situation:

In SQL Assistant i executed:  MODIFY USER "zwanl99" AS PASSWORD = "JDBC99test" ;

Then tested the login with BTEQ:

 

(py34env)[zwanl02@psaslstbl07 bteq]$ cat login_test.sql
.LOGON TDATA03/zwanl99,JDBC99test;
SELECT USER;
.LOGOFF;            /* disconnect from the DBS */

 

(py34env)[zwanl02@psaslstbl07 bteq]$ bteq <login_test.sql
BTEQ 15.10.01.00 Wed Apr 19 09:16:35 2017 PID: 16101

+---------+---------+---------+---------+---------+---------+---------+----
.LOGON TDATA03/zwanl99,

 *** Logon successfully completed.
 *** Teradata Database Release is 15.10.04.02
 *** Teradata Database Version is 15.10.04.02
 *** Transaction Semantics are BTET.
 *** Session Character Set Name is 'UTF8'.

 *** Total elapsed time was 1 second.

+---------+---------+---------+---------+---------+---------+---------+----
SELECT USER;

 *** Query completed. One row found. One column returned.
 *** Total elapsed time was 1 second.

User
---------------------------------------------------------------------------
ZWANL99

+---------+---------+---------+---------+---------+---------+---------+----
.LOGOFF;            /* disconnect from the DBS */
 *** You are now logged off from the DBC.
+---------+---------+---------+---------+---------+---------+---------+----

 *** BTEQ exiting due to EOF on stdin.
 *** Exiting BTEQ...
 *** RC (return code) = 0

 

My JAVA program (at least the first part of it):
(py34env)[zwanl02@psaslstbl07 java]$ cat test.java
import java.sql.*;
import java.text.DateFormat;
import java.util.Date;

public class test
{

    public static void main(String args[])
    throws ClassNotFoundException
    {
        String user = args[0];
        String password = args[1];
        int i = 0;
        {
        System.out.println("de user is: " + user);
        System.out.println("het WW is : " + password);
        }

       // Creation of URL to be passed to the JDBC driver. format= jdbc:teradata://DatabaseServerName/ParameterName=Value,ParameterName=Value
        String url = "jdbc:teradata://10.224.51.234/TMODE=TERA,LOGMECH=TD2,CHARSET=UTF8";
       // creation of the SELECT statement and its parameter value
        String sqlStatement = "SELECT * from dbc.dbcinfo";

        try
        {
            // Loading the Teradata JDBC driver
            Class.forName("com.teradata.jdbc.TeraDriver");
            // Creating a connection object
            Connection con = DriverManager.getConnection(url, user, password);
            try
            {
                // Creating a prepared statement object from an active connection
                PreparedStatement pstmt = con.prepareStatement(sqlStatement);
                try
                {
......
....
..

 

The file i use to run the java program:

(py34env)[zwanl02@psaslstbl07 java]$ cat ./run.sh
export CLASSPATH=".:/home/BELASTINGDIENST/zwanl02/jdbc/terajdbc4.jar:/home/BELASTINGDIENST/zwanl02/jdbc/tdgssconfig.jar:"
java test zwanl99 JDBC99test

 

Then execute the java program:

(py34env)[zwanl02@psaslstbl07 java]$ ./run.sh
de user is: zwanl99
het WW is : JDBC99test

*** SQLException caught ***
 Error code: 8017
 SQL State: 28000
 Message: [Teradata Database] [TeraJDBC 16.00.00.24] [Error 8017] [SQLState 28000] The UserId, Password or Account is invalid.
java.sql.SQLException: [Teradata Database] [TeraJDBC 16.00.00.24] [Error 8017] [SQLState 28000] The UserId, Password or Account is invalid.
        at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDatabaseSQLException(ErrorFactory.java:302)
        at com.teradata.jdbc.jdbc.GenericLogonController.run(GenericLogonController.java:617)
        at com.teradata.jdbc.jdbc_4.TDSession.<init>(TDSession.java:209)
        at com.teradata.jdbc.jdk6.JDK6_SQL_Connection.<init>(JDK6_SQL_Connection.java:36)
        at com.teradata.jdbc.jdk6.JDK6ConnectionFactory.constructSQLConnection(JDK6ConnectionFactory.java:25)
        at com.teradata.jdbc.jdbc.ConnectionFactory.createConnection(ConnectionFactory.java:179)
        at com.teradata.jdbc.jdbc.ConnectionFactory.createConnection(ConnectionFactory.java:169)
        at com.teradata.jdbc.TeraDriver.doConnect(TeraDriver.java:235)
        at com.teradata.jdbc.TeraDriver.connect(TeraDriver.java:161)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:247)
        at test.main(test.java:29)

Exception in thread "main" java.lang.IllegalStateException: Sample failed.
        at test.main(test.java:81)

 

 

So I do not see where the invalid password is coming from.

 

Enthusiast

Re: JDBC driver NullPointerException TdgssConfigApi.GetMechanisms(Unknown Source)

source of problem found.

In debug mode i see the following variables:

main[1] locals
Method arguments:
args = instance of java.lang.String[2] (id=395)
Local variables:
user = "zwanl99"
"assword = "JDBC99test

and there the password is not correct.

When changing the password variable in debug mode tot JDBC99test and continue, the connection is made without the invalid password error.

Now te figure out why the JDBC99test becomes "JDBC99test after the statement: String password = args[1]; (but that is something beyond this community).

 

Thanks everyone for your input.

regards,

Laurens

Enthusiast

Re: JDBC driver NullPointerException TdgssConfigApi.GetMechanisms(Unknown Source)

problem was the input file.

At the end of the line there was a command character which causes the wrong result of the ARGS[] instruction.

 

(py34env)[zwanl02@psaslstbl07 java]$ od -xc run.sh
0000000    7865    6f70    7472    4320    414c    5353    4150    4854
          e   x   p   o   r   t       C   L   A   S   S   P   A   T   H
0000020    223d    3a2e    682f    6d6f    2f65    4542    414c    5453
          =   "   .   :   /   h   o   m   e   /   B   E   L   A   S   T
0000040    4e49    4447    4549    534e    2f54    777a    6e61    306c
          I   N   G   D   I   E   N   S   T   /   z   w   a   n   l   0
0000060    2f32    646a    6362    742f    7265    6a61    6264    3463
          2   /   j   d   b   c   /   t   e   r   a   j   d   b   c   4
0000100    6a2e    7261    2f3a    6f68    656d    422f    4c45    5341
          .   j   a   r   :   /   h   o   m   e   /   B   E   L   A   S
0000120    4954    474e    4944    4e45    5453    7a2f    6177    6c6e
          T   I   N   G   D   I   E   N   S   T   /   z   w   a   n   l
0000140    3230    6a2f    6264    2f63    6474    7367    6373    6e6f
          0   2   /   j   d   b   c   /   t   d   g   s   s   c   o   n
0000160    6966    2e67    616a    3a72    0d22    6a0a    6264    7420
          f   i   g   .   j   a   r   :   "  \r  \n   j   d   b       t
0000200    7365    2074    777a    6e61    396c    2039    444a    4342
          e   s   t       z   w   a   n   l   9   9       J   D   B   C
0000220    3939    6574    7473    0a0d
          9   9   t   e   s   t  \r  \n