connection using JDBC giving java.lang.IllegalArgumentException

Connectivity

connection using JDBC giving java.lang.IllegalArgumentException

Hi,

I am very new to Teradata. I have simple java program to connect to terdata database and get metadata information e. column name , datatype etc. I have requirement to call this java code inside Oracle database.

Jdbc Version : 14.10.00.39

Terdata Version : 14.10.00

Oracle Version : 11.2.0.3

Java :

java version "1.5.0_30"

Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_30-b03)

Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_30-b03, mixed mode)

Standalone program works. but when I call from inside Oracle , I get following error stack

*** IllegalArgumentException caught ***

 Error code: null

java.lang.IllegalArgumentException

        at com.teradata.jdbc.jdbc_4.io.TDPacketStream.limit(TDPacketStream.java:142)

        at com.teradata.jdbc.jdbc_4.io.TDPacketStream.readStream(TDPacketStream.java:774)

        at com.teradata.jdbc.jdbc.GenericLogonController.run(GenericLogonController.java:102)

        at com.teradata.jdbc.jdbc_4.TDSession.<init>(TDSession.java:205)

        at com.teradata.jdbc.jdk14.JDK14_SQL_Connection.<init>(JDK14_SQL_Connection.java:31)

        at com.teradata.jdbc.jdbc.ConnectionFactory.constructSQLConnection(ConnectionFactory.java:106)

        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:232)

        at com.teradata.jdbc.TeraDriver.connect(TeraDriver.java:158)

        at java.sql.DriverManager.getConnection(DriverManager.java)

        at java.sql.DriverManager.getConnection(DriverManager.java:187)

        at TDTabList.GetTDList(TDTabList.java:32)

Here is DEBUG log 

2015-01-02.10:36:08.873 TERAJDBC4 TIMING [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 Hostname lookup for teradata.db.server.com took 18 ms and found 1 address(es)

2015-01-02.10:36:08.874 TERAJDBC4 DEBUG [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 Before connect loop: sm_mapConnectFailures={}

2015-01-02.10:36:08.874 TERAJDBC4 DEBUG [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 setAddresses=[teradata.db.server.com/10.17.17.120:1025]

2015-01-02.10:36:08.874 TERAJDBC4 TIMING [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 Attempting connection 1 to teradata.db.server.com/10.17.17.120:1025

2015-01-02.10:36:08.878 TERAJDBC4 TIMING [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 Connection attempt to teradata.db.server.com/10.17.17.120:1025 with timeout 10000 ms to

ok 2 ms and succeeded, waiting for thread took 0 ms

2015-01-02.10:36:08.879 TERAJDBC4 DEBUG [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 Completed connection: socket orig=teradata.db.server.com local=/10.27.28.46:30915 remot

e=teradata.db.server.com/10.17.17.120:1025 keepalive=false nodelay=false receive=131072 send=131072 linger=10 traffic=0 concurrent=3 contimeout=10000 conwait=1000 connecttime=2 connecttotaltime=5

connectattempts=1 connectfailures=0 reconnectattempts=0 recoverable=false redrive=false failurecache={} cid=f8c9f752 sess=0

2015-01-02.10:36:08.879 TERAJDBC4 DEBUG [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 Raw packet transmit: byte array length 65156 (0xfe84), offset 0 (0x0), dump length 106 (0x6a)

00000   03 01 0a 00 00 07 00 00 00 36 00 00 00 00 00 00  |.........6......|

00010   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|

00020   00 00 00 00 00 ff 00 00 00 00 00 00 00 00 00 00  |................|

00030   00 00 00 00 00 a6 00 36 00 00 00 01 00 02 00 04  |.......6........|

00040   0e 0a 00 01 00 01 00 0c 54 54 55 20 31 34 2e 31  |........TTU 14.1|

00050   30 2e 30 30 00 04 00 00 00 08 00 01 01 00 03 00  |0.00............|

00060   00 00 05 00 00 00 09 00 01 01                    |..........|

 

2015-01-02.10:36:08.880 TERAJDBC4 DEBUG [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 Thread Root Thread now owns lock: IO WriteLock

2015-01-02.10:36:08.880 TERAJDBC4 TIMING [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 Wrote Config request message, 106 bytes, time: 0 ms

2015-01-02.10:36:08.880 TERAJDBC4 DEBUG [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 Thread Root Thread attempt to unlock IO WriteLock

2015-01-02.10:36:08.881 TERAJDBC4 TIMING [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 Read Config response message 1, 1356 bytes, time: 1 ms

2015-01-02.10:36:08.882 TERAJDBC4 DEBUG [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 Raw packet receive: byte array length 65156 (0xfe84), offset 0 (0x0), dump length 1356 (0x54c)

00000   03 02 0a 00 00 07 00 00 05 18 00 00 00 00 00 00  |................|

00010   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|

...

 

2015-01-02.10:36:08.873 TERAJDBC4 TIMING [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 Hostname lookup for teradata.db.server.com took 18 ms and found 1 address(es)

2015-01-02.10:36:08.874 TERAJDBC4 DEBUG [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 Before connect loop: sm_mapConnectFailures={}

2015-01-02.10:36:08.874 TERAJDBC4 DEBUG [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 setAddresses=[teradata.db.server.com/10.17.17.120:1025]

2015-01-02.10:36:08.874 TERAJDBC4 TIMING [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 Attempting connection 1 to teradata.db.server.com/10.17.17.120:1025

2015-01-02.10:36:08.878 TERAJDBC4 TIMING [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 Connection attempt to teradata.db.server.com/10.17.17.120:1025 with timeout 10000 ms to

ok 2 ms and succeeded, waiting for thread took 0 ms

2015-01-02.10:36:08.879 TERAJDBC4 DEBUG [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 Completed connection: socket orig=teradata.db.server.com local=/10.27.28.46:30915 remot

e=teradata.db.server.com/10.17.17.120:1025 keepalive=false nodelay=false receive=131072 send=131072 linger=10 traffic=0 concurrent=3 contimeout=10000 conwait=1000 connecttime=2 connecttotaltime=5

connectattempts=1 connectfailures=0 reconnectattempts=0 recoverable=false redrive=false failurecache={} cid=f8c9f752 sess=0

2015-01-02.10:36:08.879 TERAJDBC4 DEBUG [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 Raw packet transmit: byte array length 65156 (0xfe84), offset 0 (0x0), dump length 106 (0x6a)

00000   03 01 0a 00 00 07 00 00 00 36 00 00 00 00 00 00  |.........6......|

00010   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|

00020   00 00 00 00 00 ff 00 00 00 00 00 00 00 00 00 00  |................|

00030   00 00 00 00 00 a6 00 36 00 00 00 01 00 02 00 04  |.......6........|

00040   0e 0a 00 01 00 01 00 0c 54 54 55 20 31 34 2e 31  |........TTU 14.1|

00050   30 2e 30 30 00 04 00 00 00 08 00 01 01 00 03 00  |0.00............|

00060   00 00 05 00 00 00 09 00 01 01                    |..........|

 

2015-01-02.10:36:08.880 TERAJDBC4 DEBUG [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 Thread Root Thread now owns lock: IO WriteLock

2015-01-02.10:36:08.880 TERAJDBC4 TIMING [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 Wrote Config request message, 106 bytes, time: 0 ms

2015-01-02.10:36:08.880 TERAJDBC4 DEBUG [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 Thread Root Thread attempt to unlock IO WriteLock

2015-01-02.10:36:08.881 TERAJDBC4 TIMING [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 Read Config response message 1, 1356 bytes, time: 1 ms

2015-01-02.10:36:08.882 TERAJDBC4 DEBUG [Root Thread] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@917ab4b8 Raw packet receive: byte array length 65156 (0xfe84), offset 0 (0x0), dump length 1356 (0x54c)

00000   03 02 0a 00 00 07 00 00 05 18 00 00 00 00 00 00  |................|

00010   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|

Fails with 

*** IllegalArgumentException caught ***

 Error code: null

java.lang.IllegalArgumentException

        at com.teradata.jdbc.jdbc_4.io.TDPacketStream.limit(TDPacketStream.java:142)

        at com.teradata.jdbc.jdbc_4.io.TDPacketStream.readStream(TDPacketStream.java:774)

        at com.teradata.jdbc.jdbc.GenericLogonController.run(GenericLogonController.java:102)

        at com.teradata.jdbc.jdbc_4.TDSession.<init>(TDSession.java:205)

        at com.teradata.jdbc.jdk14.JDK14_SQL_Connection.<init>(JDK14_SQL_Connection.java:31)

        at com.teradata.jdbc.jdbc.ConnectionFactory.constructSQLConnection(ConnectionFactory.java:106)

        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:232)

        at com.teradata.jdbc.TeraDriver.connect(TeraDriver.java:158)

        at java.sql.DriverManager.getConnection(DriverManager.java)

        at java.sql.DriverManager.getConnection(DriverManager.java:187)

        at TDTabList.GetTDList(TDTabList.java:32)

 


Stack trace is identical when I run it out side Oracle 

Additional Lines DEBUG lines from when from java 

003f0   01 01 00 0d 00 3e 31 34 2e 31 30 2e 30 33 2e 30  |.....>14.10.03.0|

00400   34 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  |4               |

00410   20 20 20 20 31 34 2e 31 30 2e 30 33 2e 30 34 20  |    14.10.03.04 |

00420   20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  |                |

00430   20 20 20 20 00 0e 00 04 02 02 01 02 00 0f 00 22  |    ..........."|

00440   00 01 01 00 00 01 00 01 00 00 00 01 00 01 00 01  |................|

00450   00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 01  |................|

00460   01 00 00 10 00 14 00 00 00 00 00 00 00 00 00 00  |................|

00470   80 02 00 00 00 00 00 00 00 00 00 06 00 02 01 49  |...............I|

00480   00 a5 00 38 00 00 00 01 00 01 00 05 01 00 02 00  |...8............|

00490   08 0e 0a 03 01 00 03 00 04 00 04 00 06 00 22 00  |..............".|

004a0   06 00 04 00 05 00 04 00 07 00 04 00 08 00 04 00  |................|

004b0   09 00 04 00 0a 00 05 01 00 a7 00 31 00 00 00 01  |...........1....|

004c0   00 00 00 0d 2b 06 01 04 01 81 3f 01 87 74 01 01  |....+.....?..t..|

004d0   09 00 10 00 0c 00 00 00 03 00 00 00 01 00 11 00  |................|

004e0   0c 00 00 00 01 00 00 00 14 00 a7 00 24 00 00 00  |............$...|

004f0   01 00 00 00 0c 2b 06 01 04 01 81 3f 01 87 74 01  |.....+.....?..t.|

00500   14 00 11 00 0c 00 00 00 01 00 00 00 46 00 a7 00  |............F...|

00510   21 00 00 00 01 00 00 00 09 2a 86 48 86 f7 12 01  |!........*.H....|

00520   02 02 00 11 00 0c 00 00 00 01 00 00 00 28 00 a7  |.............(..|

00530   00 1e 00 00 00 01 00 00 00 06 2b 06 01 05 05 02  |..........+.....|

00540   00 11 00 0c 00 00 00 01 00 00 00 41              |...........A|

Works here ...

2015-01-02.10:40:01.933 TERAJDBC4 DEBUG [main] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@5f934ad ParcelFactory:nextParcel flavor value: 43

2015-01-02.10:40:01.933 TERAJDBC4 DEBUG [main] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@5f934ad ParcelFactory: creating an ConfigRspParcel

2015-01-02.10:40:01.934 TERAJDBC4 DEBUG [main] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@5f934ad arraySupport=1 outParamArgSupport=1 largeDecimalBIGINT=1 generatedKeysSupport=1 m_trustedSQLSupport=1 m_byXMLSupport=1

2015-01-02.10:40:01.934 TERAJDBC4 DEBUG [main] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@5f934ad lobSupport=1 aphSupport=1 extendedRspSupport=1 positioningSupport=1 udtSupport=1 enhancedStatementStatusSupport=0 aphResponseSupport=1 s

tatementInfoSupport=1 dynamicResultSetsSupport=1 msrPositioningSupport=1 m_statementInfoRequestSupport=1 m_byUDTTransformOffSupport=2 m_byPeriodDataTypeSupport=1 m_byElicitByNameSupport=1 m_byClientAttributesSupport=1 m_nFetchRowCountSu

pport=1 m_byStatementIndependenceSupport=1 m_byArrayDataTypeSupport=1 m_byNumberDataTypeSupport=1 m_byStatementStatusLevel=1 m_byFailFastSupport=1 m_byUnityClientAttributesSupport=1 m_byRecoverableNPSupport=1 m_byRedriveSupport=0 m_byCo

ntrolDataSupport=1 m_byJsonSupport=0

2015-01-02.10:40:01.934 TERAJDBC4 DEBUG [main] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@5f934ad ParcelFactory:nextParcel flavor value: 165

2015-01-02.10:40:01.934 TERAJDBC4 DEBUG [main] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@5f934ad ParcelFactory: creating a GtwConfigParcel

2015-01-02.10:40:01.933 TERAJDBC4 DEBUG [main] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@5f934ad ParcelFactory:nextParcel flavor value: 43

2015-01-02.10:40:01.933 TERAJDBC4 DEBUG [main] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@5f934ad ParcelFactory: creating an ConfigRspParcel

2015-01-02.10:40:01.934 TERAJDBC4 DEBUG [main] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@5f934ad arraySupport=1 outParamArgSupport=1 largeDecimalBIGINT=1 generatedKeysSupport=1 m_trustedSQLSupport=1 m_byXMLSupport=1

2015-01-02.10:40:01.934 TERAJDBC4 DEBUG [main] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@5f934ad lobSupport=1 aphSupport=1 extendedRspSupport=1 positioningSupport=1 udtSupport=1 enhancedStatementStatusSupport=0 aphResponseSupport=1 s

tatementInfoSupport=1 dynamicResultSetsSupport=1 msrPositioningSupport=1 m_statementInfoRequestSupport=1 m_byUDTTransformOffSupport=2 m_byPeriodDataTypeSupport=1 m_byElicitByNameSupport=1 m_byClientAttributesSupport=1 m_nFetchRowCountSu

pport=1 m_byStatementIndependenceSupport=1 m_byArrayDataTypeSupport=1 m_byNumberDataTypeSupport=1 m_byStatementStatusLevel=1 m_byFailFastSupport=1 m_byUnityClientAttributesSupport=1 m_byRecoverableNPSupport=1 m_byRedriveSupport=0 m_byCo

ntrolDataSupport=1 m_byJsonSupport=0

2015-01-02.10:40:01.934 TERAJDBC4 DEBUG [main] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@5f934ad ParcelFactory:nextParcel flavor value: 165

2015-01-02.10:40:01.934 TERAJDBC4 DEBUG [main] com.teradata.jdbc.jdk14.JDK14_SQL_Connection@5f934ad ParcelFactory: creating a GtwConfigParcel

...

Code :

import java.io.*;
import java.sql.*;
import com.teradata.jdbc.*;

public class TDTabList
{
public static void GetTDList()
throws ClassNotFoundException
{
try
{
String sUser = "uid";
String sPassword = "pwd";

String DBName = "DB";
String TableName = "TABLE";
String ColList = "*";

String url = "jdbc:teradata://teradata.db.server.com/TMODE=ANSI,CHARSET=ASCII,LOG=DEBUG,COP=OFF";

Class.forName("com.teradata.jdbc.TeraDriver");
Connection con = DriverManager.getConnection(url, sUser, sPassword);

con.setAutoCommit(false);

try
{
String v_sql = " Select " + ColList + " from " + DBName + "." + TableName + " Where 1=2";
System.out.println("SQL :" + v_sql );

Statement stmt = con.createStatement();
try
{
ResultSet rset = stmt.executeQuery(v_sql);
ResultSetMetaData rsmd = rset.getMetaData();

String v_ColumnName;
String v_ColumnTypeName;

int colCount = rsmd.getColumnCount();
int i = 1;
int v_data_length;
int v_data_precision;
int v_data_scale;
int v_Nullable;

while(i <= colCount)
{
v_ColumnName = rsmd.getColumnName(i);
v_ColumnTypeName = rsmd.getColumnTypeName(i);
v_data_length = rsmd.getColumnDisplaySize(i);
v_data_precision = rsmd.getPrecision(i);
v_data_scale = rsmd.getScale(i);
v_Nullable = rsmd.isNullable(i);

System.out.println(rsmd.getColumnName(i)+":"+rsmd.getColumnTypeName(i)+":("+(rsmd.getPrecision(i)==0?rsmd.getColumnDisplaySize(i):rsmd.getPrecision(i))+(rsmd.getScale(i)!=0?","+

rsmd.getScale(i)+")":")"));
i++;
}
}
finally
{
stmt.close();
}
}

finally
{
con.close();
}

}

catch (SQLException ex)
{
// A SQLException was generated. Catch it and display
// the error information. Note that there could be multiple
// error objects chained together.
System.out.println();
System.out.println("*** SQLException caught ***");

while (ex != null)
{
System.out.println(" Error code: " + ex.getErrorCode());
System.out.println(" SQL State: " + ex.getSQLState());
System.out.println(" Message: " + ex.getMessage());
ex.printStackTrace();
System.out.println();
ex = ex.getNextException();
}

throw new IllegalStateException ("GetTabColumns failed.") ;
}

catch (IllegalArgumentException ex)
{
System.out.println();
System.out.println("*** IllegalArgumentException caught ***");

System.out.println(" Error code: " + ex.getMessage());
ex.printStackTrace();
System.out.println();

throw new IllegalStateException ("GetTabColumns failed.") ;
}

} // End class GetTDList

} // End class TDTabList




Any help / pointer to debug/fix this issue ?

Thanks in advance

Guru

3 REPLIES
Teradata Employee

Re: connection using JDBC giving java.lang.IllegalArgumentException

Are you attempting to use the Teradata JDBC Driver from a Java Stored Procedure running inside the Oracle Database? That is not an environment that we test with or support.

If you're a customer, then please open an incident with Teradata Customer Service. Please keep in mind that we may be limited in the support that we can provide since this is an unsupported configuration.

Re: connection using JDBC giving java.lang.IllegalArgumentException

Yes I am attempting to connect from inside Oracle DB.

I don't have access to the ticketinI will ask DBA team open a ticket for this.

>>com.teradata.jdbc.jdbc_4.io.TDPacketStream.limit(TDPac ketStream.java:142)

Is there any other debugging steps be done to what is value for Limit we hitting ? or is there a way to set the Limit ?

Thanks for the response

Guru

Teradata Employee

Re: connection using JDBC giving java.lang.IllegalArgumentException

The exception is occurring in low-level code in the Teradata JDBC Driver to deserialize the binary data received from the Teradata Database. An exception from that low-level code might be due to messages and/or data getting truncated or corrupted during transmission from the Teradata Database to the Teradata JDBC Driver.