Package ru.yandex.clickhouse.response
Class ClickHouseResultSet
- java.lang.Object
-
- ru.yandex.clickhouse.response.AbstractResultSet
-
- ru.yandex.clickhouse.response.ClickHouseResultSet
-
- All Implemented Interfaces:
AutoCloseable,ResultSet,Wrapper
- Direct Known Subclasses:
ClickHouseScrollableResultSet
public class ClickHouseResultSet extends AbstractResultSet
-
-
Field Summary
Fields Modifier and Type Field Description protected ByteFragmentnextLineprotected introwNumberprotected ByteFragment[]values-
Fields inherited from interface java.sql.ResultSet
CLOSE_CURSORS_AT_COMMIT, CONCUR_READ_ONLY, CONCUR_UPDATABLE, FETCH_FORWARD, FETCH_REVERSE, FETCH_UNKNOWN, HOLD_CURSORS_OVER_COMMIT, TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE, TYPE_SCROLL_SENSITIVE
-
-
Constructor Summary
Constructors Constructor Description ClickHouseResultSet(InputStream is, int bufferSize, String db, String table, boolean usesWithTotals, ClickHouseStatement statement, TimeZone timeZone, ClickHouseProperties properties)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclose()intfindColumn(String column)ArraygetArray(int columnIndex)ArraygetArray(String column)BigDecimalgetBigDecimal(int columnIndex)BigDecimalgetBigDecimal(int columnIndex, int scale)BigDecimalgetBigDecimal(String columnLabel)BigDecimalgetBigDecimal(String columnLabel, int scale)BigIntegergetBigInteger(int columnIndex)BigIntegergetBigInteger(String columnLabel)booleangetBoolean(int colNum)booleangetBoolean(String column)bytegetByte(int colNum)bytegetByte(String column)byte[]getBytes(int colNum)byte[]getBytes(String column)String[]getColumnNames()DategetDate(int columnIndex)DategetDate(int columnIndex, Calendar calendar)DategetDate(String columnLabel)StringgetDb()doublegetDouble(int columnIndex)doublegetDouble(String columnLabel)floatgetFloat(int columnIndex)floatgetFloat(String columnLabel)intgetInt(int colNum)intgetInt(String column)longgetLong(int colNum)longgetLong(String column)long[]getLongArray(int colNum)Deprecated.prefer to use regular JDBC APIlong[]getLongArray(String column)Parse the value in current row at column with labelcolumnas an array of longResultSetMetaDatagetMetaData()ObjectgetObject(int columnIndex)<T> TgetObject(int columnIndex, Class<T> type)ObjectgetObject(String columnLabel)<T> TgetObject(String columnLabel, Class<T> type)intgetRow()shortgetShort(int colNum)shortgetShort(String column)StatementgetStatement()StringgetString(int colNum)StringgetString(String column)StringgetTable()TimegetTime(int columnIndex)TimegetTime(int columnIndex, Calendar calendar)TimegetTime(String columnLabel)TimestampgetTimestamp(int columnIndex)TimestampgetTimestamp(int columnIndex, Calendar cal)TimestampgetTimestamp(String column)TimestampgetTimestamp(String column, Calendar cal)LonggetTimestampAsLong(int colNum)Deprecated.prefer to use regular JDBC API methods, e.g.LonggetTimestampAsLong(int colNum, TimeZone timeZone)Deprecated.prefer to use regular JDBC API methodvoidgetTotals()intgetType()ByteFragment[]getValues()Deprecated.prefer to use regular JDBC API to retrieve the resultsprotected booleanhasNext()Check if there is another row.booleanisAfterLast()booleanisBeforeFirst()booleanisClosed()booleanisFirst()booleanisLast()booleannext()voidsetFetchDirection(int direction)voidsetFetchSize(int rows)voidsetMaxRows(int maxRows)StringtoString()booleanwasNull()-
Methods inherited from class ru.yandex.clickhouse.response.AbstractResultSet
absolute, afterLast, beforeFirst, cancelRowUpdates, clearWarnings, deleteRow, first, getAsciiStream, getAsciiStream, getBinaryStream, getBinaryStream, getBlob, getBlob, getCharacterStream, getCharacterStream, getClob, getClob, getConcurrency, getCursorName, getDate, getFetchDirection, getFetchSize, getHoldability, getNCharacterStream, getNCharacterStream, getNClob, getNClob, getNString, getNString, getObject, getObject, getRef, getRef, getRowId, getRowId, getSQLXML, getSQLXML, getTime, getUnicodeStream, getUnicodeStream, getURL, getURL, getWarnings, insertRow, isWrapperFor, last, moveToCurrentRow, moveToInsertRow, previous, refreshRow, relative, rowDeleted, rowInserted, rowUpdated, unwrap, updateArray, updateArray, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateBigDecimal, updateBigDecimal, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBoolean, updateBoolean, updateByte, updateByte, updateBytes, updateBytes, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateClob, updateClob, updateClob, updateClob, updateClob, updateClob, updateDate, updateDate, updateDouble, updateDouble, updateFloat, updateFloat, updateInt, updateInt, updateLong, updateLong, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNString, updateNString, updateNull, updateNull, updateObject, updateObject, updateObject, updateObject, updateRef, updateRef, updateRow, updateRowId, updateRowId, updateShort, updateShort, updateSQLXML, updateSQLXML, updateString, updateString, updateTime, updateTime, updateTimestamp, updateTimestamp
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.sql.ResultSet
updateObject, updateObject, updateObject, updateObject
-
-
-
-
Field Detail
-
values
protected ByteFragment[] values
-
nextLine
protected ByteFragment nextLine
-
rowNumber
protected int rowNumber
-
-
Constructor Detail
-
ClickHouseResultSet
public ClickHouseResultSet(InputStream is, int bufferSize, String db, String table, boolean usesWithTotals, ClickHouseStatement statement, TimeZone timeZone, ClickHouseProperties properties) throws IOException
- Throws:
IOException
-
-
Method Detail
-
hasNext
protected boolean hasNext() throws SQLExceptionCheck if there is another row.- Returns:
trueif this result set has another row after the current cursor position,falseelse- Throws:
SQLException- if something goes wrong
-
isBeforeFirst
public boolean isBeforeFirst() throws SQLException- Specified by:
isBeforeFirstin interfaceResultSet- Overrides:
isBeforeFirstin classAbstractResultSet- Throws:
SQLException
-
isAfterLast
public boolean isAfterLast() throws SQLException- Specified by:
isAfterLastin interfaceResultSet- Overrides:
isAfterLastin classAbstractResultSet- Throws:
SQLException
-
isFirst
public boolean isFirst() throws SQLException- Specified by:
isFirstin interfaceResultSet- Overrides:
isFirstin classAbstractResultSet- Throws:
SQLException
-
isLast
public boolean isLast() throws SQLException- Specified by:
isLastin interfaceResultSet- Overrides:
isLastin classAbstractResultSet- Throws:
SQLException
-
next
public boolean next() throws SQLException- Specified by:
nextin interfaceResultSet- Overrides:
nextin classAbstractResultSet- Throws:
SQLException
-
close
public void close() throws SQLException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceResultSet- Overrides:
closein classAbstractResultSet- Throws:
SQLException
-
isClosed
public boolean isClosed() throws SQLException- Specified by:
isClosedin interfaceResultSet- Overrides:
isClosedin classAbstractResultSet- Throws:
SQLException
-
getTotals
public void getTotals() throws SQLException- Throws:
SQLException
-
getMetaData
public ResultSetMetaData getMetaData() throws SQLException
- Specified by:
getMetaDatain interfaceResultSet- Overrides:
getMetaDatain classAbstractResultSet- Throws:
SQLException
-
wasNull
public boolean wasNull() throws SQLException- Specified by:
wasNullin interfaceResultSet- Overrides:
wasNullin classAbstractResultSet- Throws:
SQLException
-
getInt
public int getInt(String column) throws SQLException
- Specified by:
getIntin interfaceResultSet- Overrides:
getIntin classAbstractResultSet- Throws:
SQLException
-
getBoolean
public boolean getBoolean(String column) throws SQLException
- Specified by:
getBooleanin interfaceResultSet- Overrides:
getBooleanin classAbstractResultSet- Throws:
SQLException
-
getLong
public long getLong(String column) throws SQLException
- Specified by:
getLongin interfaceResultSet- Overrides:
getLongin classAbstractResultSet- Throws:
SQLException
-
getString
public String getString(String column) throws SQLException
- Specified by:
getStringin interfaceResultSet- Overrides:
getStringin classAbstractResultSet- Throws:
SQLException
-
getBytes
public byte[] getBytes(String column) throws SQLException
- Specified by:
getBytesin interfaceResultSet- Overrides:
getBytesin classAbstractResultSet- Throws:
SQLException
-
getTimestamp
public Timestamp getTimestamp(String column) throws SQLException
- Specified by:
getTimestampin interfaceResultSet- Overrides:
getTimestampin classAbstractResultSet- Throws:
SQLException
-
getTimestamp
public Timestamp getTimestamp(int columnIndex) throws SQLException
- Specified by:
getTimestampin interfaceResultSet- Overrides:
getTimestampin classAbstractResultSet- Throws:
SQLException
-
getTimestamp
public Timestamp getTimestamp(String column, Calendar cal) throws SQLException
- Specified by:
getTimestampin interfaceResultSet- Overrides:
getTimestampin classAbstractResultSet- Throws:
SQLException
-
getTimestamp
public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException
- Specified by:
getTimestampin interfaceResultSet- Overrides:
getTimestampin classAbstractResultSet- Throws:
SQLException
-
getShort
public short getShort(String column) throws SQLException
- Specified by:
getShortin interfaceResultSet- Overrides:
getShortin classAbstractResultSet- Throws:
SQLException
-
getByte
public byte getByte(String column) throws SQLException
- Specified by:
getBytein interfaceResultSet- Overrides:
getBytein classAbstractResultSet- Throws:
SQLException
-
getLongArray
public long[] getLongArray(String column) throws SQLException
Description copied from class:AbstractResultSetParse the value in current row at column with labelcolumnas an array of long- Specified by:
getLongArrayin classAbstractResultSet- Parameters:
column- the label, name, alias of the column- Returns:
- an array of longs
- Throws:
SQLException- if the value cannot be interpreted aslong[]
-
getArray
public Array getArray(int columnIndex) throws SQLException
- Specified by:
getArrayin interfaceResultSet- Overrides:
getArrayin classAbstractResultSet- Throws:
SQLException
-
getArray
public Array getArray(String column) throws SQLException
- Specified by:
getArrayin interfaceResultSet- Overrides:
getArrayin classAbstractResultSet- Throws:
SQLException
-
getDouble
public double getDouble(String columnLabel) throws SQLException
- Specified by:
getDoublein interfaceResultSet- Overrides:
getDoublein classAbstractResultSet- Throws:
SQLException
-
getFloat
public float getFloat(String columnLabel) throws SQLException
- Specified by:
getFloatin interfaceResultSet- Overrides:
getFloatin classAbstractResultSet- Throws:
SQLException
-
getDate
public Date getDate(String columnLabel) throws SQLException
- Specified by:
getDatein interfaceResultSet- Overrides:
getDatein classAbstractResultSet- Throws:
SQLException
-
getTime
public Time getTime(String columnLabel) throws SQLException
- Specified by:
getTimein interfaceResultSet- Overrides:
getTimein classAbstractResultSet- Throws:
SQLException
-
getObject
public Object getObject(String columnLabel) throws SQLException
- Specified by:
getObjectin interfaceResultSet- Overrides:
getObjectin classAbstractResultSet- Throws:
SQLException
-
getString
public String getString(int colNum) throws SQLException
- Specified by:
getStringin interfaceResultSet- Overrides:
getStringin classAbstractResultSet- Throws:
SQLException
-
getInt
public int getInt(int colNum) throws SQLException- Specified by:
getIntin interfaceResultSet- Overrides:
getIntin classAbstractResultSet- Throws:
SQLException
-
getBoolean
public boolean getBoolean(int colNum) throws SQLException- Specified by:
getBooleanin interfaceResultSet- Overrides:
getBooleanin classAbstractResultSet- Throws:
SQLException
-
getLong
public long getLong(int colNum) throws SQLException- Specified by:
getLongin interfaceResultSet- Overrides:
getLongin classAbstractResultSet- Throws:
SQLException
-
getBytes
public byte[] getBytes(int colNum)
- Specified by:
getBytesin interfaceResultSet- Overrides:
getBytesin classAbstractResultSet
-
getTimestampAsLong
@Deprecated public Long getTimestampAsLong(int colNum)
Deprecated.prefer to use regular JDBC API methods, e.g.getTimestamp(int)orgetObject(int, Class)usingInstantTries to parse the value as a timestamp using the connection time zone if applicable and return its representation as milliseconds since epoch.- Parameters:
colNum- column number- Returns:
- timestamp value as milliseconds since epoch
-
getTimestampAsLong
@Deprecated public Long getTimestampAsLong(int colNum, TimeZone timeZone)
Deprecated.prefer to use regular JDBC API methodTries to parse the value as a timestamp and return its representation as milliseconds since epoch- Parameters:
colNum- the column numbertimeZone- time zone to use when parsing date / date time values- Returns:
- value interpreted as timestamp as milliseconds since epoch
-
getShort
public short getShort(int colNum) throws SQLException- Specified by:
getShortin interfaceResultSet- Overrides:
getShortin classAbstractResultSet- Throws:
SQLException
-
getByte
public byte getByte(int colNum)
- Specified by:
getBytein interfaceResultSet- Overrides:
getBytein classAbstractResultSet
-
getLongArray
@Deprecated public long[] getLongArray(int colNum) throws SQLException
Deprecated.prefer to use regular JDBC APIParse the value in current row at column indexcolNumas an array of long- Parameters:
colNum- column number- Returns:
- an array of longs
- Throws:
SQLException- if the value cannot be interpreted aslong[]
-
getFloat
public float getFloat(int columnIndex) throws SQLException- Specified by:
getFloatin interfaceResultSet- Overrides:
getFloatin classAbstractResultSet- Throws:
SQLException
-
getDouble
public double getDouble(int columnIndex) throws SQLException- Specified by:
getDoublein interfaceResultSet- Overrides:
getDoublein classAbstractResultSet- Throws:
SQLException
-
getStatement
public Statement getStatement()
- Specified by:
getStatementin interfaceResultSet- Overrides:
getStatementin classAbstractResultSet
-
getDate
public Date getDate(int columnIndex) throws SQLException
- Specified by:
getDatein interfaceResultSet- Overrides:
getDatein classAbstractResultSet- Throws:
SQLException
-
getDate
public Date getDate(int columnIndex, Calendar calendar) throws SQLException
- Specified by:
getDatein interfaceResultSet- Overrides:
getDatein classAbstractResultSet- Throws:
SQLException
-
getTime
public Time getTime(int columnIndex) throws SQLException
- Specified by:
getTimein interfaceResultSet- Overrides:
getTimein classAbstractResultSet- Throws:
SQLException
-
getTime
public Time getTime(int columnIndex, Calendar calendar) throws SQLException
- Specified by:
getTimein interfaceResultSet- Overrides:
getTimein classAbstractResultSet- Throws:
SQLException
-
getObject
public Object getObject(int columnIndex) throws SQLException
- Specified by:
getObjectin interfaceResultSet- Overrides:
getObjectin classAbstractResultSet- Throws:
SQLException
-
getType
public int getType() throws SQLException- Specified by:
getTypein interfaceResultSet- Overrides:
getTypein classAbstractResultSet- Throws:
SQLException
-
getRow
public int getRow() throws SQLException- Throws:
SQLException
-
getDb
public String getDb()
-
getTable
public String getTable()
-
setMaxRows
public void setMaxRows(int maxRows)
-
findColumn
public int findColumn(String column) throws SQLException
- Specified by:
findColumnin interfaceResultSet- Overrides:
findColumnin classAbstractResultSet- Throws:
SQLException
-
getObject
public <T> T getObject(int columnIndex, Class<T> type) throws SQLException- Throws:
SQLException
-
getObject
public <T> T getObject(String columnLabel, Class<T> type) throws SQLException
- Throws:
SQLException
-
getValues
@Deprecated public ByteFragment[] getValues()
Deprecated.prefer to use regular JDBC API to retrieve the resultsRetrieve the results in "raw" form.- Returns:
- the results as an array of
ByteFragments
-
getBigDecimal
public BigDecimal getBigDecimal(String columnLabel) throws SQLException
- Specified by:
getBigDecimalin interfaceResultSet- Overrides:
getBigDecimalin classAbstractResultSet- Throws:
SQLException
-
getBigDecimal
public BigDecimal getBigDecimal(int columnIndex) throws SQLException
- Specified by:
getBigDecimalin interfaceResultSet- Overrides:
getBigDecimalin classAbstractResultSet- Throws:
SQLException
-
getBigDecimal
public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException
- Specified by:
getBigDecimalin interfaceResultSet- Overrides:
getBigDecimalin classAbstractResultSet- Throws:
SQLException
-
getBigDecimal
public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException
- Specified by:
getBigDecimalin interfaceResultSet- Overrides:
getBigDecimalin classAbstractResultSet- Throws:
SQLException
-
getBigInteger
public BigInteger getBigInteger(String columnLabel) throws SQLException
- Throws:
SQLException
-
getBigInteger
public BigInteger getBigInteger(int columnIndex) throws SQLException
- Throws:
SQLException
-
getColumnNames
public String[] getColumnNames()
-
setFetchDirection
public void setFetchDirection(int direction) throws SQLException- Specified by:
setFetchDirectionin interfaceResultSet- Overrides:
setFetchDirectionin classAbstractResultSet- Throws:
SQLException
-
setFetchSize
public void setFetchSize(int rows) throws SQLException- Specified by:
setFetchSizein interfaceResultSet- Overrides:
setFetchSizein classAbstractResultSet- Throws:
SQLException
-
-