JDBC : getBytes() throws error for int column?

Connectivity

JDBC : getBytes() throws error for int column?

I am calling getBytes(column) method on an integer column, but its throwing following exception.

According to JDBC documentation, I thought getBytes() method reads raw bytes regardless of the column type.

Is this an exception for Teradata JDBC driver?

Caused by: java.sql.SQLException: [Teradata JDBC Driver] [TeraJDBC 16.20.00.04] [Error 616] [SQLState HY000] ResultSet:getBytes function failed: java.lang.Integer
	at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:95)
	at com.teradata.jdbc.jdbc_4.util.ErrorFactory.makeDriverJDBCException(ErrorFactory.java:70)
	at com.teradata.jdbc.jdbc_4.TDResultSet.internalGetBytes(TDResultSet.java:1167)
	at com.teradata.jdbc.jdbc_4.TDResultSet.getBytes(TDResultSet.java:1871)
	at com.xxxx.xxxx.dataplatform.ingest.infrastructure.extract.impl.Hdfs.write(Hdfs.java:125)

 

1 REPLY
Teradata Employee

Re: JDBC : getBytes() throws error for int column?

>>> I thought getBytes() method reads raw bytes regardless of the column type

 

No, the Teradata JDBC Driver's ResultSet.getBytes method does not work that way.

 

The Teradata JDBC Driver's ResultSet.getBytes method is intended for use with BYTE and VARBYTE column values.

 

The Teradata JDBC Driver User Guide provides a table listing all data types and corresponding ResultSet getter methods that may be used with each column value data type:

 

http://developer.teradata.com/doc/connectivity/jdbc/reference/current/jdbcug_chapter_7.html