private Object getColumnValue(int columnIndex) throws SQLException { if (row == null) { throw new SQLException("No row found."); } if (row.length == 0) { throw new SQLException("RowSet does not contain any columns!"); } if (columnIndex > row.length) { throw new SQLException("Invalid columnIndex: " + columnIndex); } Type columnType = getSchema().getColumnDescriptorAt(columnIndex - 1).getType(); try { Object evaluated = evaluate(columnType, row[columnIndex - 1]); wasNull = evaluated == null; return evaluated; } catch (Exception e) { e.printStackTrace(); throw new SQLException("Unrecognized column type:" + columnType, e); } }
@Test public void testGetFunctions() throws Exception { SessionHandle sessionHandle = client.openSession("tom", "password"); assertNotNull(sessionHandle); OperationHandle opHandle = client.getFunctions(sessionHandle, null, null, "*"); TableSchema schema = client.getResultSetMetadata(opHandle); ColumnDescriptor columnDesc = schema.getColumnDescriptorAt(0); assertEquals("FUNCTION_CAT", columnDesc.getName()); assertEquals(Type.STRING_TYPE, columnDesc.getType()); columnDesc = schema.getColumnDescriptorAt(1); assertEquals("FUNCTION_SCHEM", columnDesc.getName()); assertEquals(Type.STRING_TYPE, columnDesc.getType()); columnDesc = schema.getColumnDescriptorAt(2); assertEquals("FUNCTION_NAME", columnDesc.getName()); assertEquals(Type.STRING_TYPE, columnDesc.getType()); columnDesc = schema.getColumnDescriptorAt(3); assertEquals("REMARKS", columnDesc.getName()); assertEquals(Type.STRING_TYPE, columnDesc.getType()); columnDesc = schema.getColumnDescriptorAt(4); assertEquals("FUNCTION_TYPE", columnDesc.getName()); assertEquals(Type.INT_TYPE, columnDesc.getType()); columnDesc = schema.getColumnDescriptorAt(5); assertEquals("SPECIFIC_NAME", columnDesc.getName()); assertEquals(Type.STRING_TYPE, columnDesc.getType()); // Cleanup client.closeOperation(opHandle); client.closeSession(sessionHandle); }
private Object getColumnValue(int columnIndex) throws SQLException { if (row == null) { throw new SQLException("No row found."); } if (row.length == 0) { throw new SQLException("RowSet does not contain any columns!"); } if (columnIndex > row.length) { throw new SQLException("Invalid columnIndex: " + columnIndex); } Type columnType = getSchema().getColumnDescriptorAt(columnIndex - 1).getType(); try { Object evaluated = evaluate(columnType, row[columnIndex - 1]); wasNull = evaluated == null; return evaluated; } catch (Exception e) { e.printStackTrace(); throw new SQLException("Unrecognized column type:" + columnType, e); } }
private Object getColumnValue(int columnIndex) throws SQLException { if (row == null) { throw new SQLException("No row found."); } if (row.length == 0) { throw new SQLException("RowSet does not contain any columns!"); } if (columnIndex > row.length) { throw new SQLException("Invalid columnIndex: " + columnIndex); } Type columnType = getSchema().getColumnDescriptorAt(columnIndex - 1).getType(); try { Object evaluated = evaluate(columnType, row[columnIndex - 1]); wasNull = evaluated == null; return evaluated; } catch (Exception e) { e.printStackTrace(); throw new SQLException("Unrecognized column type:" + columnType, e); } }
private Object getColumnValue(int columnIndex) throws SQLException { if (row == null) { throw new SQLException("No row found."); } if (row.length == 0) { throw new SQLException("RowSet does not contain any columns!"); } if (columnIndex > row.length) { throw new SQLException("Invalid columnIndex: " + columnIndex); } Type columnType = getSchema().getColumnDescriptorAt(columnIndex - 1).getType(); try { Object evaluated = evaluate(columnType, row[columnIndex - 1]); wasNull = evaluated == null; return evaluated; } catch (Exception e) { e.printStackTrace(); throw new SQLException("Unrecognized column type:" + columnType, e); } }