Teradata JDBC Driver Not Cancelling Statement

Tools & Utilities
Enthusiast

Re: Teradata JDBC Driver Not Cancelling Statement


@tomnolan wrote:

When your app calls the ResultSet.next method to fetch a row, and the JDBC Driver has no more rows in its buffer, then the JDBC Driver transmits a Continue Request message to fetch another set of rows from the database.


If these messages are continuing after I stop calling resultSet.next(), is it possible that these messages are delayed from a previous resultSet.next()? As per the snippet I posted, once I "cancel" the query, I have also stopped calling resultSet.next() but the messages keep flowing in. I understand that cancelling the statement doesn't stop these messages BUT running a new query on the statement does stop these messages from flowing in.

 

This leads to me to believe that there is something explicitly happening in the driver to stop the messages from flowing in which is NOT tied to resultSet.next().

Enthusiast

Re: Teradata JDBC Driver Not Cancelling Statement

 
Highlighted
Teradata Employee

Re: Teradata JDBC Driver Not Cancelling Statement

There is no reason to call the "cancel" method here. And even if you do, it will not generate an exception that would stop the other thread from being able to continue fetching data. You must use some other approach to stop fetching.

 

If you continue to see Continue Request messages, then your application is actually still calling resultSet.next().

 

(BTW: Logging off = closing the connection)

Enthusiast

Re: Teradata JDBC Driver Not Cancelling Statement

I discovered that the extra streaming data was due to a call to "getMoreResults" from my app. It seems like that one call to "getMoreResults" caused up to several millions of rows to be streamed from the teradata jdbc driver. Do you know if that's expected behavior?

 

PS: I've been able to stop streaming the extra data. Thanks.

Teradata Employee

Re: Teradata JDBC Driver Not Cancelling Statement

The behavior you observed for getMoreResults method is expected if your Statement object was created with result set type = ResultSet.TYPE_FORWARD_ONLY.

 

The behavior of the Teradata JDBC Driver's getMoreResults method depends on whether the Statement object was created to produce forward-only result sets (meaning result set type = ResultSet.TYPE_FORWARD_ONLY) or produce scrollable result sets (meaning result set type = ResultSet.TYPE_SCROLL_INSENSITIVE).

 

If the Statement has result set type = ResultSet.TYPE_FORWARD_ONLY, then the JDBC Driver does not use the Teradata Database's Cursor Positioning feature, which means that when your app calls the getMoreResults method, the JDBC Driver cannot skip to a subsequent result set produced by a multi-statement request, and instead the JDBC Driver must fetch through all the rows of the current result set in order to advance to the next result set.

 

On the other hand, if the Statement has result set type = ResultSet.TYPE_SCROLL_INSENSITIVE, then the JDBC Driver uses the Teradata Database's Cursor Positioning feature, which means that when your app calls the getMoreResults method, the JDBC Driver directly skips to a subsequent result set produced by a multi-statement request, and the JDBC Driver can avoid fetching through all the rows of the current result set in order to advance to the next result set.