Error Message

The following methods sometimes fail with the "SE_WRONG_COLUMN_TYPE" error after attempting to read an integer column from a database table (or feature class):

· ArcSDE 8.0.2 Java API methods:

¤ Stream.getInteger
¤ Stream.getSmallint

· ArcSDE 8.1 Java API methods:

¤ SeRow.getInteger
¤ SeRow.getShort


ArcSDE classifies the column type of RDBMS columns containing integer values as either TYPE_INTEGER or TYPE_SMALLINT. It may not be apparent from the width of the column which type the column will be classified as.

If a column read from a record (row) from a stream is classified by ArcSDE as TYPE_INTEGER, it must be retrieved using getInteger(). If the column is classified as TYPE_SMALLINT, it must be read with either Stream.getSmallint (ArcSDE 8.0.x) or SeRow.getShort (ArcSDE 8.1.x).

Solution or Workaround

Get the column type of each column on the stream. Stream or row functions are provided to retrieve the column definition for a particular column, and ColumnDefinition methods are also available for extracting the column type from the column definition.

Search the ArcSDE Java API documentation for the ColumnDefinition class to see a list of all ArcSDE column types.

Example for ArcSDE 8.0.x:

. . .
Stream strm = new Stream(pbcsde);
. . .
ColumnDefinition colDef = new ColumnDefinition();
int colNum = 1;
strm.describeColumn(colNum, colDef);
int myColumnVal = 0;
switch (colDef.type)
case com.esri.sde.client.ColumnDefinition.TYPE_INTEGER:
System.out.println("Column " + colNum + " is an TYPE_INTEGER");
myColumnVal = strm.getInteger(colNum);

case com.esri.sde.client.ColumnDefinition.TYPE_SMALLINT:
System.out.println("Column " + colNum + " is a TYPE_SMALLINT");
short tempShort = strm.getSmallint(colNum);
myColumnVal = tempShort;
System.out.println("Column " + colNum + "'s value: " + myColumnVal);
. . .

Example for ArcSDE 8.1.x:

. . .
sqlConstruct = new SeSqlConstruct( layer.getName());
String[] cols = new String[1];
cols[0] = new String("ColumnOneName");
SeQuery query = new SeQuery( conn, cols, sqlConstruct );
SeRow row = query.fetch();
SeColumnDefinition[] colDefs = SeRow.getColumns();
int colNum = 0;
int dataType = colDefs[colNum].getType;
switch( dataType )
case SeColumnDefinition.TYPE_INTEGER:
System.out.println(colDef.getName(colNum) + row.getInteger(colNum));
. . .
. . .