FileDocCategorySizeDatePackage
JDBCResultSet.javaAPI DocAndroid 1.5 API25640Wed May 06 22:41:06 BST 2009SQLite.JDBC2y

JDBCResultSet

public class JDBCResultSet extends Object implements ResultSet

Fields Summary
private int
row
Current row to be retrieved.
protected SQLite.TableResult
tr
Table returned by Database.get_table()
private JDBCStatement
s
Statement from which result set was produced.
private JDBCResultSetMetaData
m
Meta data for result set or null.
private String
lastg
Last result cell retrieved or null.
Constructors Summary
public JDBCResultSet(SQLite.TableResult tr, JDBCStatement s)

    this.tr = tr;
    this.s = s;
    this.m = null;
    this.lastg = null;
    this.row = -1;
    
Methods Summary
public booleanabsolute(int row)

    if (tr == null) {
        return false;
    }
    if (row < 0) {
        row = tr.nrows + 1 + row;
    }
    row--;
    if (row < 0 || row > tr.nrows) {
        return false;
    }
    this.row = row;
    return true;
    
public voidafterLast()

    if (tr == null) {
        return;
    }
    row = tr.nrows;
    
public voidbeforeFirst()

    if (tr == null) {
        return;
    }
    row = -1;
    
public voidcancelRowUpdates()

    throw new SQLException("not supported");
    
public voidclearWarnings()

    throw new SQLException("not supported");
    
public voidclose()

    s = null;
    tr = null;
    lastg = null;
    row = -1;
    
public voiddeleteRow()

    throw new SQLException("not supported");
    
public intfindColumn(java.lang.String columnName)

    JDBCResultSetMetaData m = (JDBCResultSetMetaData) getMetaData();
    return m.findColByName(columnName);
    
public booleanfirst()

    if (tr == null || tr.nrows <= 0) {
        return false;
    }
    row = 0;
    return true;
    
public java.sql.ArraygetArray(int columnIndex)

    throw new SQLException("not supported");
    
public java.sql.ArraygetArray(java.lang.String columnIndex)

    throw new SQLException("not supported");
    
public java.io.InputStreamgetAsciiStream(java.lang.String columnName)

    throw new SQLException("not supported");
    
public java.io.InputStreamgetAsciiStream(int columnIndex)

    throw new SQLException("not supported");
    
public java.math.BigDecimalgetBigDecimal(java.lang.String columnName)

    throw new SQLException("not supported");
    
public java.math.BigDecimalgetBigDecimal(java.lang.String columnName, int scale)

    throw new SQLException("not supported");
    
public java.math.BigDecimalgetBigDecimal(int columnIndex)

    throw new SQLException("not supported");
    
public java.math.BigDecimalgetBigDecimal(int columnIndex, int scale)

    throw new SQLException("not supported");
    
public java.io.InputStreamgetBinaryStream(int columnIndex)

    throw new SQLException("not supported");
    
public java.io.InputStreamgetBinaryStream(java.lang.String columnName)

    throw new SQLException("not supported");
    
public java.sql.BlobgetBlob(int columnIndex)

    throw new SQLException("not supported");
    
public java.sql.BlobgetBlob(java.lang.String columnIndex)

    throw new SQLException("not supported");
    
public booleangetBoolean(int columnIndex)

    throw new SQLException("not supported");
    
public booleangetBoolean(java.lang.String columnName)

    throw new SQLException("not supported");
    
public bytegetByte(int columnIndex)

    throw new SQLException("not supported");
    
public bytegetByte(java.lang.String columnName)

    throw new SQLException("not supported");
    
public byte[]getBytes(int columnIndex)

    if (tr == null || columnIndex < 1 || columnIndex > tr.ncolumns) {
        throw new SQLException("column " + columnIndex + " not found");
    }
    byte ret[] = null;
    String rd[] = (String []) tr.rows.elementAt(row);
    lastg = rd[columnIndex - 1];
    if (lastg != null) {
        ret = SQLite.StringEncoder.decode(lastg);
    }
    return ret;
    
public byte[]getBytes(java.lang.String columnName)

    int col = findColumn(columnName);
    return getBytes(col);
    
public java.io.ReadergetCharacterStream(int columnIndex)

    throw new SQLException("not supported");
    
public java.io.ReadergetCharacterStream(java.lang.String columnName)

    throw new SQLException("not supported");
    
public java.sql.ClobgetClob(int columnIndex)

    throw new SQLException("not supported");
    
public java.sql.ClobgetClob(java.lang.String columnIndex)

    throw new SQLException("not supported");
    
public intgetConcurrency()

    return CONCUR_READ_ONLY;
    
public java.lang.StringgetCursorName()

    return null;
    
public java.sql.DategetDate(int columnIndex)

    return internalGetDate(columnIndex, null);
    
public java.sql.DategetDate(java.lang.String columnName)

    int col = findColumn(columnName);
    return getDate(col);
    
public java.sql.DategetDate(int columnIndex, java.util.Calendar cal)

    return internalGetDate(columnIndex, cal);
    
public java.sql.DategetDate(java.lang.String columnName, java.util.Calendar cal)

    int col = findColumn(columnName);
    return getDate(col, cal);
    
public doublegetDouble(int columnIndex)

    Double d = internalGetDouble(columnIndex);
    if (d != null) {
        return d.doubleValue();
    }
    return 0;
    
public doublegetDouble(java.lang.String columnName)

    int col = findColumn(columnName);
    return getDouble(col);
    
public intgetFetchDirection()

    throw new SQLException("not supported");
    
public intgetFetchSize()

    throw new SQLException("not supported");
    
public floatgetFloat(int columnIndex)

    Float f = internalGetFloat(columnIndex);
    if (f != null) {
        return f.floatValue();
    }
    return 0;
    
public floatgetFloat(java.lang.String columnName)

    int col = findColumn(columnName);
    return getFloat(col);
    
public intgetInt(int columnIndex)

    Integer i = internalGetInt(columnIndex);
    if (i != null) {
        return i.intValue();
    }
    return 0;
    
public intgetInt(java.lang.String columnName)

    int col = findColumn(columnName);
    return getInt(col);
    
public longgetLong(int columnIndex)

    Long l = internalGetLong(columnIndex);
    if (l != null) {
        return l.longValue();
    }
    return 0;
    
public longgetLong(java.lang.String columnName)

    int col = findColumn(columnName);
    return getLong(col);
    
public java.sql.ResultSetMetaDatagetMetaData()

    if (m == null) {
        m = new JDBCResultSetMetaData(this);
    }
    return m;
    
public java.lang.ObjectgetObject(int columnIndex)

    if (tr == null || columnIndex < 1 || columnIndex > tr.ncolumns) {
        throw new SQLException("column " + columnIndex + " not found");
    }
    String rd[] = (String []) tr.rows.elementAt(row);
    lastg = rd[columnIndex - 1];
    Object ret = lastg;
    if (tr instanceof TableResultX) {
        switch (((TableResultX) tr).sql_type[columnIndex - 1]) {
        case Types.SMALLINT:
        ret = internalGetShort(columnIndex);
        break;
        case Types.INTEGER:
        ret = internalGetInt(columnIndex);
        break;
        case Types.DOUBLE:
        ret = internalGetDouble(columnIndex);
        break;
        case Types.FLOAT:
        ret = internalGetFloat(columnIndex);
        break;
        case Types.BIGINT:
        ret = internalGetLong(columnIndex);
        break;
        case Types.BINARY:
        case Types.VARBINARY:
        case Types.LONGVARBINARY:
        ret = getBytes(columnIndex);
        break;
        case Types.NULL:
        ret = null;
        break;
        /* defaults to String below */
        }
    }
    return ret;
    
public java.lang.ObjectgetObject(java.lang.String columnName)

    int col = findColumn(columnName);
    return getObject(col);
    
public java.lang.ObjectgetObject(int columnIndex, java.util.Map map)

    throw new SQLException("not supported");
    
public java.lang.ObjectgetObject(java.lang.String columnIndex, java.util.Map map)

    throw new SQLException("not supported");
    
public java.sql.RefgetRef(int columnIndex)

    throw new SQLException("not supported");
    
public java.sql.RefgetRef(java.lang.String columnIndex)

    throw new SQLException("not supported");
    
public intgetRow()

    if (tr == null) {
        throw new SQLException("no rows");
    }
    return row + 1;
    
public shortgetShort(int columnIndex)

    Short s = internalGetShort(columnIndex);
    if (s != null) {
        return s.shortValue();
    }
    return 0;
    
public shortgetShort(java.lang.String columnName)

    int col = findColumn(columnName);
    return getShort(col);
    
public java.sql.StatementgetStatement()

    if (s == null) {
        throw new SQLException("stale result set");
    }
    return s;
    
public java.lang.StringgetString(int columnIndex)

    if (tr == null || columnIndex < 1 || columnIndex > tr.ncolumns) {
        throw new SQLException("column " + columnIndex + " not found");
    }
    String rd[] = (String []) tr.rows.elementAt(row);
    lastg = rd[columnIndex - 1];
    return lastg;
    
public java.lang.StringgetString(java.lang.String columnName)

    int col = findColumn(columnName);
    return getString(col);
    
public java.sql.TimegetTime(int columnIndex)

    return internalGetTime(columnIndex, null);
    
public java.sql.TimegetTime(java.lang.String columnName)

    int col = findColumn(columnName);
    return getTime(col);
    
public java.sql.TimegetTime(int columnIndex, java.util.Calendar cal)

    return internalGetTime(columnIndex, cal);
    
public java.sql.TimegetTime(java.lang.String columnName, java.util.Calendar cal)

    int col = findColumn(columnName);
    return getTime(col, cal);
    
public java.sql.TimestampgetTimestamp(int columnIndex)

    return internalGetTimestamp(columnIndex, null);
    
public java.sql.TimestampgetTimestamp(java.lang.String columnName)

    int col = findColumn(columnName);
    return getTimestamp(col);
    
public java.sql.TimestampgetTimestamp(int columnIndex, java.util.Calendar cal)

    return internalGetTimestamp(columnIndex, cal);
    
public java.sql.TimestampgetTimestamp(java.lang.String columnName, java.util.Calendar cal)

    int col = findColumn(columnName);
    return getTimestamp(col, cal);
    
public intgetType()

    return TYPE_SCROLL_INSENSITIVE;
    
public java.net.URLgetURL(int colIndex)

    if (tr == null || colIndex < 1 || colIndex > tr.ncolumns) {
        throw new SQLException("column " + colIndex + " not found");
    }
    String rd[] = (String []) tr.rows.elementAt(row);
    lastg = rd[colIndex - 1];
    java.net.URL url = null;
    if (lastg == null) {
        return url;
    }
    try {
        url = new java.net.URL(lastg);
    } catch (java.lang.Exception e) {
        url = null;
    }
    return url;
    
public java.net.URLgetURL(java.lang.String colIndex)

    int col = findColumn(colIndex);
    return getURL(col);
    
public java.io.InputStreamgetUnicodeStream(int columnIndex)

    throw new SQLException("not supported");
    
public java.io.InputStreamgetUnicodeStream(java.lang.String columnName)

    throw new SQLException("not supported");
    
public java.sql.SQLWarninggetWarnings()

    throw new SQLException("not supported");
    
public voidinsertRow()

    throw new SQLException("not supported");
    
private java.sql.DateinternalGetDate(int columnIndex, java.util.Calendar cal)

    if (tr == null || columnIndex < 1 || columnIndex > tr.ncolumns) {
        throw new SQLException("column " + columnIndex + " not found");
    }
    String rd[] = (String []) tr.rows.elementAt(row);
    lastg = rd[columnIndex - 1];
    try {
        return java.sql.Date.valueOf(lastg);
    } catch (java.lang.Exception e) {
        lastg = null;
    }
    return null;
    
private java.lang.DoubleinternalGetDouble(int columnIndex)

    if (tr == null || columnIndex < 1 || columnIndex > tr.ncolumns) {
        throw new SQLException("column " + columnIndex + " not found");
    }
    String rd[] = (String []) tr.rows.elementAt(row);
    lastg = rd[columnIndex - 1];
    try {
        return  Double.valueOf(lastg);
    } catch (java.lang.Exception e) {
        lastg = null;
    }
    return null;
    
private java.lang.FloatinternalGetFloat(int columnIndex)

    if (tr == null || columnIndex < 1 || columnIndex > tr.ncolumns) {
        throw new SQLException("column " + columnIndex + " not found");
    }
    String rd[] = (String []) tr.rows.elementAt(row);
    lastg = rd[columnIndex - 1];
    try {
        return Float.valueOf(lastg);
    } catch (java.lang.Exception e) {
        lastg = null;
    }
    return null;
    
private java.lang.IntegerinternalGetInt(int columnIndex)

    if (tr == null || columnIndex < 1 || columnIndex > tr.ncolumns) {
        throw new SQLException("column " + columnIndex + " not found");
    }
    String rd[] = (String []) tr.rows.elementAt(row);
    lastg = rd[columnIndex - 1];
    try {
        return Integer.valueOf(lastg);
    } catch (java.lang.Exception e) {
        lastg = null;
    }
    return null;
    
private java.lang.LonginternalGetLong(int columnIndex)

    if (tr == null || columnIndex < 1 || columnIndex > tr.ncolumns) {
        throw new SQLException("column " + columnIndex + " not found");
    }
    String rd[] = (String []) tr.rows.elementAt(row);
    lastg = rd[columnIndex - 1];
    try {
        return Long.valueOf(lastg);
    } catch (java.lang.Exception e) {
        lastg = null;
    }
    return null;
    
private java.lang.ShortinternalGetShort(int columnIndex)

    if (tr == null || columnIndex < 1 || columnIndex > tr.ncolumns) {
        throw new SQLException("column " + columnIndex + " not found");
    }
    String rd[] = (String []) tr.rows.elementAt(row);
    lastg = rd[columnIndex - 1];
    try {
        return Short.valueOf(lastg);
    } catch (java.lang.Exception e) {
        lastg = null;
    }
    return null;
    
private java.sql.TimeinternalGetTime(int columnIndex, java.util.Calendar cal)

    if (tr == null || columnIndex < 1 || columnIndex > tr.ncolumns) {
        throw new SQLException("column " + columnIndex + " not found");
    }
    String rd[] = (String []) tr.rows.elementAt(row);
    lastg = rd[columnIndex - 1];
    try {
        return java.sql.Time.valueOf(lastg);
    } catch (java.lang.Exception e) {
        lastg = null;
    }
    return null;
    
private java.sql.TimestampinternalGetTimestamp(int columnIndex, java.util.Calendar cal)

    if (tr == null || columnIndex < 1 || columnIndex > tr.ncolumns) {
        throw new SQLException("column " + columnIndex + " not found");
    }
    String rd[] = (String []) tr.rows.elementAt(row);
    lastg = rd[columnIndex - 1];
    try {
        return java.sql.Timestamp.valueOf(lastg);
    } catch (java.lang.Exception e) {
        lastg = null;
    }
    return null;
    
public booleanisAfterLast()

    if (tr == null || tr.nrows <= 0) {
        return false;
    }
    return row >= tr.nrows;
    
public booleanisBeforeFirst()

    if (tr == null || tr.nrows <= 0) {
        return false;
    }
    return row < 0;
    
public booleanisFirst()

    if (tr == null) {
        return true;
    }
    return row == 0;
    
public booleanisLast()

    if (tr == null) {
        return true;
    }
    return row == tr.nrows - 1;
    
public booleanlast()

    if (tr == null || tr.nrows <= 0) {
        return false;
    }
    row = tr.nrows -1;
    return true;
    
public voidmoveToCurrentRow()

    throw new SQLException("not supported");
    
public voidmoveToInsertRow()

    throw new SQLException("not supported");
    
public booleannext()

    if (tr == null) {
        return false;
    }
    row++;
    return row < tr.nrows;
    
public booleanprevious()

    if (tr == null) {
        return false;
    }
    if (row >= 0) {
        row--;
    }
    return row >= 0;
    
public voidrefreshRow()

    throw new SQLException("not supported");
    
public booleanrelative(int row)

    if (tr == null) {
        return false;
    }
    if (this.row + row < 0 || this.row + row >= tr.nrows) {
        return false;
    }
    this.row += row;
    return true;
    
public booleanrowDeleted()

    throw new SQLException("not supported");
    
public booleanrowInserted()

    throw new SQLException("not supported");
    
public booleanrowUpdated()

    throw new SQLException("not supported");
    
public voidsetFetchDirection(int dir)

    throw new SQLException("not supported");
    
public voidsetFetchSize(int fsize)

    throw new SQLException("not supported");
    
public voidupdateArray(int colIndex, java.sql.Array x)

    throw new SQLException("not supported");
    
public voidupdateArray(java.lang.String colIndex, java.sql.Array x)

    throw new SQLException("not supported");
    
public voidupdateAsciiStream(int colIndex, java.io.InputStream in, int s)

    throw new SQLException("not supported");
    
public voidupdateAsciiStream(java.lang.String colIndex, java.io.InputStream in, int s)

    throw new SQLException("not supported");
    
public voidupdateBigDecimal(int colIndex, java.math.BigDecimal f)

    throw new SQLException("not supported");
    
public voidupdateBigDecimal(java.lang.String colIndex, java.math.BigDecimal f)

    throw new SQLException("not supported");
    
public voidupdateBinaryStream(int colIndex, java.io.InputStream in, int s)

    throw new SQLException("not supported");
    
public voidupdateBinaryStream(java.lang.String colIndex, java.io.InputStream in, int s)

    throw new SQLException("not supported");
    
public voidupdateBlob(int colIndex, java.sql.Blob x)

    throw new SQLException("not supported");
    
public voidupdateBlob(java.lang.String colIndex, java.sql.Blob x)

    throw new SQLException("not supported");
    
public voidupdateBoolean(int colIndex, boolean b)

    throw new SQLException("not supported");
    
public voidupdateBoolean(java.lang.String colIndex, boolean b)

    throw new SQLException("not supported");
    
public voidupdateByte(int colIndex, byte b)

    throw new SQLException("not supported");
    
public voidupdateByte(java.lang.String colIndex, byte b)

    throw new SQLException("not supported");
    
public voidupdateBytes(int colIndex, byte[] s)

    throw new SQLException("not supported");
    
public voidupdateBytes(java.lang.String colIndex, byte[] s)

    throw new SQLException("not supported");
    
public voidupdateCharacterStream(int colIndex, java.io.Reader in, int s)

    throw new SQLException("not supported");
    
public voidupdateCharacterStream(java.lang.String colIndex, java.io.Reader in, int s)

    throw new SQLException("not supported");
    
public voidupdateClob(int colIndex, java.sql.Clob x)

    throw new SQLException("not supported");
    
public voidupdateClob(java.lang.String colIndex, java.sql.Clob x)

    throw new SQLException("not supported");
    
public voidupdateDate(int colIndex, java.sql.Date d)

    throw new SQLException("not supported");
    
public voidupdateDate(java.lang.String colIndex, java.sql.Date d)

    throw new SQLException("not supported");
    
public voidupdateDouble(int colIndex, double f)

    throw new SQLException("not supported");
    
public voidupdateDouble(java.lang.String colIndex, double f)

    throw new SQLException("not supported");
    
public voidupdateFloat(int colIndex, float f)

    throw new SQLException("not supported");
    
public voidupdateFloat(java.lang.String colIndex, float f)

    throw new SQLException("not supported");
    
public voidupdateInt(int colIndex, int b)

    throw new SQLException("not supported");
    
public voidupdateInt(java.lang.String colIndex, int b)

    throw new SQLException("not supported");
    
public voidupdateLong(int colIndex, long b)

    throw new SQLException("not supported");
    
public voidupdateLong(java.lang.String colIndex, long b)

    throw new SQLException("not supported");
    
public voidupdateNull(java.lang.String colIndex)

    throw new SQLException("not supported");
    
public voidupdateNull(int colIndex)

    throw new SQLException("not supported");
    
public voidupdateObject(int colIndex, java.lang.Object obj)

    throw new SQLException("not supported");
    
public voidupdateObject(int colIndex, java.lang.Object obj, int s)

    throw new SQLException("not supported");
    
public voidupdateObject(java.lang.String colIndex, java.lang.Object obj)

    throw new SQLException("not supported");
    
public voidupdateObject(java.lang.String colIndex, java.lang.Object obj, int s)

    throw new SQLException("not supported");
    
public voidupdateRef(int colIndex, java.sql.Ref x)

    throw new SQLException("not supported");
    
public voidupdateRef(java.lang.String colIndex, java.sql.Ref x)

    throw new SQLException("not supported");
    
public voidupdateRow()

    throw new SQLException("not supported");
    
public voidupdateShort(int colIndex, short b)

    throw new SQLException("not supported");
    
public voidupdateShort(java.lang.String colIndex, short b)

    throw new SQLException("not supported");
    
public voidupdateString(int colIndex, java.lang.String s)

    throw new SQLException("not supported");
    
public voidupdateString(java.lang.String colIndex, java.lang.String s)

    throw new SQLException("not supported");
    
public voidupdateTime(int colIndex, java.sql.Time t)

    throw new SQLException("not supported");
    
public voidupdateTime(java.lang.String colIndex, java.sql.Time t)

    throw new SQLException("not supported");
    
public voidupdateTimestamp(int colIndex, java.sql.Timestamp t)

    throw new SQLException("not supported");
    
public voidupdateTimestamp(java.lang.String colIndex, java.sql.Timestamp t)

    throw new SQLException("not supported");
    
public booleanwasNull()

    return lastg == null;