select * works but not "select count(*)" via JDBC

Teradata Applications
Enthusiast

select * works but not "select count(*)" via JDBC

I am running queries through a JDBC driver. I am able to execute select * from DBC.AccessRights with no issue. However, when I execute "SELECT COUNT(*) FROM DBC.AccessRights" I get the following error. Any help is appreciated. I can run both queries from bteq on the server.

2013-03-14.11:09:04.955 TERAJDBC4 ERROR [thread applet-elation.Main-2] com.teradata.jdbc.jdk6.JDK6_SQL_Connection@8e4ac25 Read message 1: Incomplete LAN message header: read 0 bytes

2013-03-14.11:09:04.962 TERAJDBC4 ERROR [thread applet-elation.Main-2] com.teradata.jdbc.jdk6.JDK6_SQL_Connection@8e4ac25 Read message 1 failed; closing socket due to: java.io.IOException: Incomplete LAN message header: read 0 bytes

2013-03-14.11:09:05.047 TERAJDBC4 ERROR [thread applet-elation.Main-2] com.teradata.jdbc.jdk6.JDK6_SQL_Connection@8e4ac25 Packet receive Thu Mar 14 11:09:05 PDT 2013 socket orig=ec2-50-19-2-147.compute-1.amazonaws.com local=0.0.0.0/0.0.0.0:52596 remote=ec2-50-19-2-147.compute-1.amazonaws.com/50.19.2.147:1025 keepalive=unavailable nodelay=unavailable receive=unavailable send=unavailable linger=unavailable traffic=unavailable concurrent=3 contimeout=10000 conwait=1000 connecttime=85 connecttotaltime=88 connectattempts=1 connectfailures=0 failurecache={} cid=642df736 sess=3273 java.io.IOException: Incomplete LAN message header: read 0 bytes  at com.teradata.jdbc.jdbc_4.io.TDNetworkIOIF.read(TDNetworkIOIF.java:689)  at com.teradata.jdbc.jdbc_4.io.TDPacketStream.readStream(TDPacketStream.java:831)  at com.teradata.jdbc.jdbc_4.statemachine.StatementReceiveState.action(StatementReceiveState.java:144)  at com.teradata.jdbc.jdbc_4.statemachine.StatementController.runBody(StatementController.java:122)  at com.teradata.jdbc.jdbc_4.statemachine.StatementController.run(StatementController.java:113)  at com.teradata.jdbc.jdbc_4.TDStatement.executeStatement(TDStatement.java:380)  at com.teradata.jdbc.jdbc_4.TDStatement.executeStatement(TDStatement.java:322)  at com.teradata.jdbc.jdbc_4.TDStatement.doNonPrepExecuteQuery(TDStatement.java:310)  at com.teradata.jdbc.jdbc_4.TDStatement.executeQuery(TDStatement.java:1085)  at elation.base.DBConnection.query(DBConnection.java:88)  at elation.profiler.Profiler.getCount(Profiler.java:63)  at elation.profiler.Profiler.getProfile(Profiler.java:79)  at elation.Main.work(Main.java:92)  at elation.Main.start(Main.java:110)  at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.start(Unknown Source)  at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)  at java.lang.Thread.run(Thread.java:722)

com.teradata.jdbc.jdbc_4.util.JDBCException: [Teradata JDBC Driver] [TeraJDBC 14.00.00.33] [Error 804] [SQLState 08S01] Socket communication failure for Packet receive Thu Mar 14 11:09:05 PDT 2013 socket orig=ec2-50-19-2-147.compute-1.amazonaws.com local=0.0.0.0/0.0.0.0:52596 remote=ec2-50-19-2-147.compute-1.amazonaws.com/50.19.2.147:1025 keepalive=unavailable nodelay=unavailable receive=unavailable send=unavailable linger=unavailable traffic=unavailable concurrent=3 contimeout=10000 conwait=1000 connecttime=85 connecttotaltime=88 connectattempts=1 connectfailures=0 failurecache={} cid=642df736 sess=3273 java.io.IOException: Incomplete LAN message header: read 0 bytes  at com.teradata.jdbc.jdbc_4.io.TDNetworkIOIF.read(TDNetworkIOIF.java:689)  at com.teradata.jdbc.jdbc_4.io.TDPacketStream.readStream(TDPacketStream.java:831)  at com.teradata.jdbc.jdbc_4.statemachine.StatementReceiveState.action(StatementReceiveState.java:144)  at com.teradata.jdbc.jdbc_4.statemachine.StatementController.runBody(StatementController.java:122)  at com.teradata.jdbc.jdbc_4.statemachine.StatementController.run(StatementController.java:113)  at com.teradata.jdbc.jdbc_4.TDStatement.executeStatement(TDStatement.java:380)  at com.teradata.jdbc.jdbc_4.TDStatement.executeStatement(TDStatement.java:322)  at com.teradata.jdbc.jdbc_4.TDStatement.doNonPrepExecuteQuery(TDStatement.java:310)  at com.teradata.jdbc.jdbc_4.TDStatement.executeQuery(TDStatement.java:1085)  at elation.base.DBConnection.query(DBConnection.java:88)  at elation.profiler.Profiler.getCount(Profiler.java:63)  at elation.profiler.Profiler.getProfile(Profiler.java:79)  at elation.Main.work(Main.java:92)  at elation.Main.start(Main.java:110)  at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.start(Unknown Source)  at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)  at java.lang.Thread.run(Thread.java:722)

    at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:93)

    at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:68)

    at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeIoJDBCException(ErrorFactory.java:206)

    at com.teradata.jdbc.jdbc_4.util.ErrorAnalyzer.analyzeIoError(ErrorAnalyzer.java:61)

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

    at com.teradata.jdbc.jdbc_4.statemachine.StatementReceiveState.action(StatementReceiveState.java:144)

    at com.teradata.jdbc.jdbc_4.statemachine.StatementController.runBody(StatementController.java:122)

    at com.teradata.jdbc.jdbc_4.statemachine.StatementController.run(StatementController.java:113)

    at com.teradata.jdbc.jdbc_4.TDStatement.executeStatement(TDStatement.java:380)

    at com.teradata.jdbc.jdbc_4.TDStatement.executeStatement(TDStatement.java:322)

    at com.teradata.jdbc.jdbc_4.TDStatement.doNonPrepExecuteQuery(TDStatement.java:310)

    at com.teradata.jdbc.jdbc_4.TDStatement.executeQuery(TDStatement.java:1085)

    at elation.base.DBConnection.query(DBConnection.java:88)

    at elation.profiler.Profiler.getCount(Profiler.java:63)

    at elation.profiler.Profiler.getProfile(Profiler.java:79)

    at elation.Main.work(Main.java:92)

    at elation.Main.start(Main.java:110)

    at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.start(Unknown Source)

    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)

    at java.lang.Thread.run(Thread.java:722)

Caused by: java.io.IOException: Incomplete LAN message header: read 0 bytes

    at com.teradata.jdbc.jdbc_4.io.TDNetworkIOIF.read(TDNetworkIOIF.java:689)

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

    ... 15 more

Tags (1)
5 REPLIES
Enthusiast

Re: select * works but not "select count(*)" via JDBC

It works if I prepareStatement and then execute it. Not clear why - I thought preparation is only required for parameterized queries - select count(*) isn't a parameterized query.

Teradata Employee

Re: select * works but not "select count(*)" via JDBC

It is supported to do a select count(*) from DBC.AccessRights. I just tested that using Teradata JDBC Driver 14.00.00.33 with several different Teradata Database releases.

Your exception text indicates that a socket communication failure occurred: [Error 804] [SQLState 08S01] Socket communication failure ...

Did this problem only occur once? Or is the problem reproducible?

Did you examine /var/log/messages on the Teradata Database server to see if any problems are reported there?

Re: select * works but not "select count(*)" via JDBC

Was this issue resolved?  I have got the same problem but it is on an user table, "select count(*)" always failure.

Re: select * works but not "select count(*)" via JDBC

Stack trace as following:

 Failed query: "SELECT CAST(COUNT(*) AS BIGINT) AS "a1" FROM "qac"."Alldatatypes1" "table1" WHERE

    ("table1"."C_LONGVARCHAR" >= 'A' AND "table1"."C_LONGVARCHAR" <= 'L')".  [data-3923000]

Cause: [Teradata JDBC Driver] [TeraJDBC 14.10.00.17] [Error 804] [SQLState 08S01] Socket

    communication failure for Packet receive Mon Dec 02 00:40:43 PST 2013 socket orig=cstg-dv-ted-02

    local=0.0.0.0/0.0.0.0:11486 remote=cstg-dv-ted-02/172.23.7.136:1025 keepalive=unavailable

    nodelay=unavailable receive=unavailable send=unavailable linger=unavailable traffic=unavailable

    concurrent=3 contimeout=10000 conwait=1000 connecttime=0 connecttotaltime=0 connectattempts=1

    connectfailures=0 failurecache={cstg-dv-ted-01/172.23.7.135:1025=Mon Dec 02 00:34:11 PST 2013,

    cstg-dv-ted-02/172.23.7.136:1025=Mon Dec 02 00:39:06 PST 2013} cid=196a08e sess=6197

    java.io.IOException: Incomplete LAN message header: read 0 bytes   at

    com.teradata.jdbc.jdbc_4.io.TDNetworkIOIF.read(TDNetworkIOIF.java:689)   at

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

    com.teradata.jdbc.jdbc_4.statemachine.StatementReceiveState.action(StatementReceiveState.java:144)

    at

    com.teradata.jdbc.jdbc_4.statemachine.StatementController.runBody(StatementController.java:123)

    at com.teradata.jdbc.jdbc_4.statemachine.StatementController.run(StatementController.java:114)

    at com.teradata.jdbc.jdbc_4.TDStatement.executeStatement(TDStatement.java:381)   at

    com.teradata.jdbc.jdbc_4.TDStatement.executeStatement(TDStatement.java:323)   at

    com.teradata.jdbc.jdbc_4.TDStatement.doNonPrepExecuteQuery(TDStatement.java:311)   at

    com.teradata.jdbc.jdbc_4.TDStatement.executeQuery(TDStatement.java:1087)   at

Teradata Employee

Re: select * works but not "select count(*)" via JDBC

Did this problem only occur once? Or is the problem reproducible?

Did you examine /var/log/messages on the Teradata Database server to see if any problems are reported there?