public interface IResultSet extends IRemoteObject {

	// JDBC ResultSet methods
	public boolean absolute(int row) throws SQLException, RemoteException;
	public void afterLast() throws SQLException, RemoteException;
	public void beforeFirst() throws SQLException, RemoteException;
	public void cancelRowUpdates() throws SQLException, RemoteException;
	public void clearWarnings() throws SQLException, RemoteException;
	public void close() throws SQLException, RemoteException;
	public void deleteRow() throws SQLException, RemoteException;
	public int findColumn(String columnName) throws SQLException, RemoteException;
	public boolean first() throws SQLException, RemoteException;
	public SArray getArray(int columnIndex) throws SQLException, RemoteException;
	public SArray getArray(String colName) throws SQLException, RemoteException;
	public SInputStream getAsciiStream(int columnIndex) throws SQLException, RemoteException;
	public SInputStream getAsciiStream(String columnName) throws SQLException, RemoteException;
	public BigDecimal getBigDecimal(int columnIndex) throws SQLException, RemoteException;
	public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException, RemoteException;
	public BigDecimal getBigDecimal(String columnName) throws SQLException, RemoteException;
	public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException, RemoteException;
	public SInputStream getBinaryStream(int columnIndex) throws SQLException, RemoteException;
	public SInputStream getBinaryStream(String columnName) throws SQLException, RemoteException;
	public SBlob getBlob(int columnIndex) throws SQLException, RemoteException;
	public SBlob getBlob(String columnName) throws SQLException, RemoteException;
	public boolean getBoolean(int columnIndex) throws SQLException, RemoteException;
	public boolean getBoolean(String columnName) throws SQLException, RemoteException;
	public byte getByte(int columnIndex) throws SQLException, RemoteException;
	public byte getByte(String columnName) throws SQLException, RemoteException;
	public byte[] getBytes(int columnIndex) throws SQLException, RemoteException;
	public byte[] getBytes(String columnName) throws SQLException, RemoteException;
	public SReader getCharacterStream(int columnIndex) throws SQLException, RemoteException;
	public SReader getCharacterStream(String columnName) throws SQLException, RemoteException;
	public SClob getClob(int columnIndex) throws SQLException, RemoteException;
	public SClob getClob(String colName) throws SQLException, RemoteException;
	public int getConcurrency() throws SQLException, RemoteException;
	public String getCursorName() throws SQLException, RemoteException;
	public Date getDate(int columnIndex) throws SQLException, RemoteException;
	public Date getDate(int columnIndex, Calendar cal) throws SQLException, RemoteException;
	public Date getDate(String columnName) throws SQLException, RemoteException;
	public Date getDate(String columnName, Calendar cal) throws SQLException, RemoteException;
	public double getDouble(int columnIndex) throws SQLException, RemoteException;
	public double getDouble(String columnName) throws SQLException, RemoteException;
	public int getFetchDirection() throws SQLException, RemoteException;
	public int getFetchSize() throws SQLException, RemoteException;
	public float getFloat(int columnIndex) throws SQLException, RemoteException;
	public float getFloat(String columnName) throws SQLException, RemoteException;
	public int getInt(int columnIndex) throws SQLException, RemoteException;
	public int getInt(String columnName) throws SQLException, RemoteException;
	public long getLong(int columnIndex) throws SQLException, RemoteException;
	public long getLong(String columnName) throws SQLException, RemoteException;
	public IResultSetMetaData getMetaData() throws SQLException, RemoteException;
	public Object getObject(int columnIndex) throws SQLException, RemoteException;
	public Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException, RemoteException;
	public Object getObject(String columnName) throws SQLException, RemoteException;
	public Object getObject(String columnName, Map<String, Class<?>> map) throws SQLException, RemoteException;
	public SRef getRef(int columnIndex) throws SQLException, RemoteException;
	public SRef getRef(String colName) throws SQLException, RemoteException;
	public int getRow() throws SQLException, RemoteException;
	public short getShort(int columnIndex) throws SQLException, RemoteException;
	public short getShort(String columnName) throws SQLException, RemoteException;
	public String getString(int columnIndex) throws SQLException, RemoteException;
	public String getString(String columnName) throws SQLException, RemoteException;
	public Time getTime(int columnIndex) throws SQLException, RemoteException;
	public Time getTime(int columnIndex, Calendar cal) throws SQLException, RemoteException;
	public Time getTime(String columnName) throws SQLException, RemoteException;
	public Time getTime(String columnName, Calendar cal) throws SQLException, RemoteException;
	public Timestamp getTimestamp(int columnIndex) throws SQLException, RemoteException;
	public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException, RemoteException;
	public Timestamp getTimestamp(String columnName) throws SQLException, RemoteException;
	public Timestamp getTimestamp(String columnName, Calendar cal) throws SQLException, RemoteException;
	public int getType() throws SQLException, RemoteException;
	public SInputStream getUnicodeStream(int columnIndex) throws SQLException, RemoteException;
	public SInputStream getUnicodeStream(String columnName) throws SQLException, RemoteException;
	public URL getURL(int columnIndex) throws SQLException, RemoteException;
	public URL getURL(String columnName) throws SQLException, RemoteException;
	public SQLWarning getWarnings() throws SQLException, RemoteException;
	public void insertRow() throws SQLException, RemoteException;
	public boolean isAfterLast() throws SQLException, RemoteException;
	public boolean isBeforeFirst() throws SQLException, RemoteException;
	public boolean isFirst() throws SQLException, RemoteException;
	public boolean isLast() throws SQLException, RemoteException;
	public boolean last() throws SQLException, RemoteException;
	public void moveToCurrentRow() throws SQLException, RemoteException;
	public void moveToInsertRow() throws SQLException, RemoteException;
	public boolean next() throws SQLException, RemoteException;
	public boolean previous() throws SQLException, RemoteException;
	public void refreshRow() throws SQLException, RemoteException;
	public boolean relative(int rows) throws SQLException, RemoteException;
	public boolean rowDeleted() throws SQLException, RemoteException;
	public boolean rowInserted() throws SQLException, RemoteException;
	public boolean rowUpdated() throws SQLException, RemoteException;
	public void setFetchDirection(int direction) throws SQLException, RemoteException;
	public void setFetchSize(int rows) throws SQLException, RemoteException;
	public void updateArray(int columnIndex, SArray x) throws SQLException, RemoteException;
	public void updateArray(String columnName, SArray x) throws SQLException, RemoteException;
	public void updateAsciiStream(int columnIndex, SInputStream x, int length) throws SQLException, RemoteException;
	public void updateAsciiStream(String columnName, SInputStream x, int length) throws SQLException, RemoteException;
	public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException, RemoteException;
	public void updateBigDecimal(String columnName, BigDecimal x) throws SQLException, RemoteException;
	public void updateBinaryStream(int columnIndex, SInputStream x, int length) throws SQLException, RemoteException;
	public void updateBinaryStream(String columnName, SInputStream x, int length) throws SQLException, RemoteException;
	public void updateBlob(int columnIndex, SBlob x) throws SQLException, RemoteException;
	public void updateBlob(String columnName, SBlob x) throws SQLException, RemoteException;
	public void updateBoolean(int columnIndex, boolean x) throws SQLException, RemoteException;
	public void updateBoolean(String columnName, boolean x) throws SQLException, RemoteException;
	public void updateByte(int columnIndex, byte x) throws SQLException, RemoteException;
	public void updateByte(String columnName, byte x) throws SQLException, RemoteException;
	public void updateBytes(int columnIndex, byte[] x) throws SQLException, RemoteException;
	public void updateBytes(String columnName, byte[] x) throws SQLException, RemoteException;
	public void updateCharacterStream(int columnIndex, SReader x, int length) throws SQLException, RemoteException;
	public void updateCharacterStream(String columnName, SReader reader, int length) throws SQLException, RemoteException;
	public void updateClob(int columnIndex, SClob x) throws SQLException, RemoteException;
	public void updateClob(String columnName, SClob x) throws SQLException, RemoteException;
	public void updateDate(int columnIndex, Date x) throws SQLException, RemoteException;
	public void updateDate(String columnName, Date x) throws SQLException, RemoteException;
	public void updateDouble(int columnIndex, double x) throws SQLException, RemoteException;
	public void updateDouble(String columnName, double x) throws SQLException, RemoteException;
	public void updateFloat(int columnIndex, float x) throws SQLException, RemoteException;
	public void updateFloat(String columnName, float x) throws SQLException, RemoteException;
	public void updateInt(int columnIndex, int x) throws SQLException, RemoteException;
	public void updateInt(String columnName, int x) throws SQLException, RemoteException;
	public void updateLong(int columnIndex, long x) throws SQLException, RemoteException;
	public void updateLong(String columnName, long x) throws SQLException, RemoteException;
	public void updateNull(int columnIndex) throws SQLException, RemoteException;
	public void updateNull(String columnName) throws SQLException, RemoteException;
	public void updateObject(int columnIndex, Object x) throws SQLException, RemoteException;
	public void updateObject(int columnIndex, Object x, int scale) throws SQLException, RemoteException;
	public void updateObject(String columnName, Object x) throws SQLException, RemoteException;
	public void updateObject(String columnName, Object x, int scale) throws SQLException, RemoteException;
	public void updateRef(int columnIndex, SRef x) throws SQLException, RemoteException;
	public void updateRef(String columnName, SRef x) throws SQLException, RemoteException;
	public void updateRow() throws SQLException, RemoteException;
	public void updateShort(int columnIndex, short x) throws SQLException, RemoteException;
	public void updateShort(String columnName, short x) throws SQLException, RemoteException;
	public void updateString(int columnIndex, String x) throws SQLException, RemoteException;
	public void updateString(String columnName, String x) throws SQLException, RemoteException;
	public void updateTime(int columnIndex, Time x) throws SQLException, RemoteException;
	public void updateTime(String columnName, Time x) throws SQLException, RemoteException;
	public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException, RemoteException;
	public void updateTimestamp(String columnName, Timestamp x) throws SQLException, RemoteException;
	public boolean wasNull() throws SQLException, RemoteException;
	public SRowId getRowId(int columnIndex) throws SQLException, RemoteException;
	public SRowId getRowId(String columnLabel) throws SQLException, RemoteException;
	public void updateRowId(int columnIndex, SRowId x) throws SQLException, RemoteException;
	public void updateRowId(String columnLabel, SRowId x) throws SQLException, RemoteException;
	public int getHoldability() throws SQLException, RemoteException;
	public boolean isClosed() throws SQLException, RemoteException;
	public void updateNString(int columnIndex, String nString) throws SQLException, RemoteException;
	public void updateNString(String columnLabel, String nString) throws SQLException, RemoteException;
	public void updateNClob(int columnIndex, SNClob nClob) throws SQLException, RemoteException;
	public void updateNClob(String columnLabel, SNClob nClob) throws SQLException, RemoteException;
	public SNClob getNClob(int columnIndex) throws SQLException, RemoteException;
	public SNClob getNClob(String columnLabel) throws SQLException, RemoteException;
	public SSQLXML getSQLXML(int columnIndex) throws SQLException, RemoteException;
	public SSQLXML getSQLXML(String columnLabel) throws SQLException, RemoteException;
	public void updateSQLXML(int columnIndex, SSQLXML xmlObject) throws SQLException, RemoteException;
	public void updateSQLXML(String columnLabel, SSQLXML xmlObject) throws SQLException, RemoteException;
	public String getNString(int columnIndex) throws SQLException, RemoteException;
	public String getNString(String columnLabel) throws SQLException, RemoteException;
	public SReader getNCharacterStream(int columnIndex) throws SQLException, RemoteException;
	public SReader getNCharacterStream(String columnLabel) throws SQLException, RemoteException;
	public void updateNCharacterStream(int columnIndex, SReader x, long length) throws SQLException, RemoteException;
	public void updateNCharacterStream(String columnLabel, SReader reader, long length) throws SQLException, RemoteException;
	public void updateAsciiStream(int columnIndex, SInputStream x, long length) throws SQLException, RemoteException;
	public void updateBinaryStream(int columnIndex, SInputStream x, long length) throws SQLException, RemoteException;
	public void updateCharacterStream(int columnIndex, SReader x, long length) throws SQLException, RemoteException;
	public void updateAsciiStream(String columnLabel, SInputStream x, long length) throws SQLException, RemoteException;
	public void updateBinaryStream(String columnLabel, SInputStream x, long length) throws SQLException, RemoteException;
	public void updateCharacterStream(String columnLabel, SReader reader, long length) throws SQLException, RemoteException;
	public void updateBlob(int columnIndex, SInputStream inputStream, long length) throws SQLException, RemoteException;
	public void updateBlob(String columnLabel, SInputStream inputStream, long length) throws SQLException, RemoteException;
	public void updateClob(int columnIndex, SReader reader, long length) throws SQLException, RemoteException;
	public void updateClob(String columnLabel, SReader reader, long length) throws SQLException, RemoteException;
	public void updateNClob(int columnIndex, SReader reader, long length) throws SQLException, RemoteException;
	public void updateNClob(String columnLabel, SReader reader, long length) throws SQLException, RemoteException;
	public void updateNCharacterStream(int columnIndex, SReader x) throws SQLException, RemoteException;
	public void updateNCharacterStream(String columnLabel, SReader reader) throws SQLException, RemoteException;
	public void updateAsciiStream(int columnIndex, SInputStream x) throws SQLException, RemoteException;
	public void updateBinaryStream(int columnIndex, SInputStream x) throws SQLException, RemoteException;
	public void updateCharacterStream(int columnIndex, SReader x) throws SQLException, RemoteException;
	public void updateAsciiStream(String columnLabel, SInputStream x) throws SQLException, RemoteException;
	public void updateBinaryStream(String columnLabel, SInputStream x) throws SQLException, RemoteException;
	public void updateCharacterStream(String columnLabel, SReader reader) throws SQLException, RemoteException;
	public void updateBlob(int columnIndex, SInputStream inputStream) throws SQLException, RemoteException;
	public void updateBlob(String columnLabel, SInputStream inputStream) throws SQLException, RemoteException;
	public void updateClob(int columnIndex, SReader reader) throws SQLException, RemoteException;
	public void updateClob(String columnLabel, SReader reader) throws SQLException, RemoteException;
	public void updateNClob(int columnIndex, SReader reader) throws SQLException, RemoteException;
	public void updateNClob(String columnLabel, SReader reader) throws SQLException, RemoteException;

	// Extra methods
	public Object[] _getObjects() throws SQLException, RemoteException;
	public Object[][] _readRows(int count) throws SQLException, RemoteException;
	public Object[] _next() throws SQLException, RemoteException;
}
 public class SArray extends SerializableObject implements Array {

	private static final long serialVersionUID = 1L;

	public static SArray create(Array w) {
		if(w==null) {
			return null;
		}
		if(w instanceof SArray) {
			return (SArray)w;
		}
		throw new IllegalStateException();
	}
	
	public SArray() {
		throw notImplementedException();
	}

	public Object getArray() throws SQLException {
		throw notImplementedException();
	}

	public Object getArray(long index, int count) throws SQLException {
		throw notImplementedException();
	}

	public Object getArray(long index, int count, Map<String, Class<?>> map) throws SQLException {
		throw notImplementedException();
	}

	public Object getArray(Map<String, Class<?>> map) throws SQLException {
		throw notImplementedException();
	}

	public int getBaseType() throws SQLException {
		throw notImplementedException();
	}

	public String getBaseTypeName() throws SQLException {
		throw notImplementedException();
	}

	public ResultSet getResultSet() throws SQLException {
		throw notImplementedException();
	}

	public ResultSet getResultSet(long index, int count) throws SQLException {
		throw notImplementedException();
	}

	public ResultSet getResultSet(long index, int count, Map<String, Class<?>> map) throws SQLException {
		throw notImplementedException();
	}

	public ResultSet getResultSet(Map<String, Class<?>> map) throws SQLException {
		throw notImplementedException();
	}

	public void free() throws SQLException {
		throw notImplementedException();
	}	
}
 public class SBlob extends SerializableObject implements Blob {

	private static final long serialVersionUID = 1L;

	public static SBlob create(Blob w) {
		if(w==null) {
			return null;
		}
		if(w instanceof SBlob) {
			return (SBlob)w;
		}
		throw new IllegalStateException();
	}
	
	public SBlob() {
		throw notImplementedException();
	}

	public InputStream getBinaryStream() throws SQLException {
		throw notImplementedException();
	}

	public byte[] getBytes(long pos, int length) throws SQLException {
		throw notImplementedException();
	}

	public long length() throws SQLException {
		throw notImplementedException();
	}

	public long position(Blob pattern, long start) throws SQLException {
		throw notImplementedException();
	}

	public long position(byte[] pattern, long start) throws SQLException {
		throw notImplementedException();
	}

	public OutputStream setBinaryStream(long pos) throws SQLException {
		throw notImplementedException();
	}

	public int setBytes(long pos, byte[] theBytes) throws SQLException {
		throw notImplementedException();
	}

	public int setBytes(long pos, byte[] theBytes, int offset, int len) throws SQLException {
		throw notImplementedException();
	}

	public void truncate(long len) throws SQLException {
		throw notImplementedException();
	}

	public void free() throws SQLException {
		throw notImplementedException();
	}

	public InputStream getBinaryStream(long pos, long length) throws SQLException {
		throw notImplementedException();
	}
}
 public class SClob extends SerializableObject implements Clob {

	private static final long serialVersionUID = 1L;

	public static SClob create(Clob w) {
		if(w==null) {
			return null;
		}
		if(w instanceof SClob) {
			return (SClob)w;
		}
		throw new IllegalStateException();
	}
	
	public SClob() {
		throw notImplementedException();
	}

	public InputStream getAsciiStream() throws SQLException {
		throw notImplementedException();
	}

	public Reader getCharacterStream() throws SQLException {
		throw notImplementedException();
	}

	public String getSubString(long pos, int length) throws SQLException {
		throw notImplementedException();
	}

	public long length() throws SQLException {
		throw notImplementedException();
	}

	public long position(Clob searchstr, long start) throws SQLException {
		throw notImplementedException();
	}

	public long position(String searchstr, long start) throws SQLException {
		throw notImplementedException();
	}

	public OutputStream setAsciiStream(long pos) throws SQLException {
		throw notImplementedException();
	}

	public Writer setCharacterStream(long pos) throws SQLException {
		throw notImplementedException();
	}

	public int setString(long pos, String str) throws SQLException {
		throw notImplementedException();
	}

	public int setString(long pos, String str, int offset, int len) throws SQLException {
		throw notImplementedException();
	}

	public void truncate(long len) throws SQLException {
		throw notImplementedException();
	}

	public void free() throws SQLException {
		throw notImplementedException();
	}

	public Reader getCharacterStream(long pos, long length) throws SQLException {
		throw notImplementedException();
	}	
}
 public class SInputStream extends SerializableObject {
	
	private static final long serialVersionUID = 1L;
	
	public static SInputStream create(InputStream w) {
		throw new IllegalStateException();
	}
	public static InputStream getInputStream(SInputStream w) {
		throw new IllegalStateException();
	}
	public static byte[] getByteArray(SInputStream w) {
		throw new IllegalStateException();
	}
	
	private SInputStream() {
		// should be public for serialization...
		throw new IllegalStateException();
	}
}
 public class SNClob extends SClob implements NClob {
	
	private static final long serialVersionUID = 1L;

	public static SNClob create(NClob w) {
		if(w==null) {
			return null;
		}
		if(w instanceof SNClob) {
			return (SNClob)w;
		}
		throw new IllegalStateException();
	}

	public SNClob() {
		throw notImplementedException();
	}
}
 public class SReader extends SerializableObject {
	
	private static final long serialVersionUID = 1L;
	
	public static SReader create(Reader w) {
		throw new IllegalStateException();
	}
	public static Reader getReader(SReader w) {
		throw new IllegalStateException();
	}
	
	private SReader() {
		// should be public for serialization...
		throw new IllegalStateException();
	}
} public class SRef extends SerializableObject implements Ref {

	private static final long serialVersionUID = 1L;
	
	public static SRef create(Ref w) {
		if(w==null) {
			return null;
		}
		if(w instanceof SRef) {
			return (SRef)w;
		}
		throw new IllegalStateException();
	}
	
	public SRef() {
		throw notImplementedException();
	}

	public String getBaseTypeName() throws SQLException {
		throw notImplementedException();
	}

	public Object getObject() throws SQLException {
		throw notImplementedException();
	}

	public Object getObject(Map<String, Class<?>> map) throws SQLException {
		throw notImplementedException();
	}

	public void setObject(Object value) throws SQLException {
		throw notImplementedException();
	}

}
 public class SRowId extends SerializableObject implements RowId {

	private static final long serialVersionUID = 1L;

	public static SRowId create(RowId w) {
		if(w==null) {
			return null;
		}
		if(w instanceof SRowId) {
			return (SRowId)w;
		}
		throw new IllegalStateException();
	}
	
	public SRowId() {
		throw notImplementedException();
	}

	public byte[] getBytes() {
		throw notImplementedException();
	}
	
}
 public class SSQLXML extends SerializableObject implements SQLXML {

	private static final long serialVersionUID = 1L;
	
	public static SSQLXML create(SQLXML w) {
		if(w==null) {
			return null;
		}
		if(w instanceof SSQLXML) {
			return (SSQLXML)w;
		}
		throw new IllegalStateException();
	}

	public SSQLXML() {
		throw notImplementedException();
	}
	
	public void free() throws SQLException {
		throw notImplementedException();
	}

	public InputStream getBinaryStream() throws SQLException {
		throw notImplementedException();
	}

	public OutputStream setBinaryStream() throws SQLException {
		throw notImplementedException();
	}

	public Reader getCharacterStream() throws SQLException {
		throw notImplementedException();
	}

	public Writer setCharacterStream() throws SQLException {
		throw notImplementedException();
	}

	public String getString() throws SQLException {
		throw notImplementedException();
	}

	public void setString(String value) throws SQLException {
		throw notImplementedException();
	}

	public <T extends Source> T getSource(Class<T> sourceClass) throws SQLException {
		throw notImplementedException();
	}

	public <T extends Result> T setResult(Class<T> resultClass) throws SQLException {
		throw notImplementedException();
	}

}
 public class SerializableObject implements ISerializable, Serializable {

	public static Serializable create(Object o) throws SQLException {
		if(o!=null) {
			if( o instanceof Serializable ) {
				return (Serializable)o;
			}
			if( o instanceof Array) {
				return SArray.create((Array)o);
			}
			if( o instanceof Blob) {
				return SBlob.create((Blob)o);
			}
			if( o instanceof Clob) {
				return SClob.create((Clob)o);
			}
			if( o instanceof InputStream) {
				return SInputStream.create((InputStream)o);
			}
			if( o instanceof NClob) {
				return SNClob.create((NClob)o);
			}
			if( o instanceof OutputStream) {
				return SOutputStream.create((OutputStream)o);
			}
			if( o instanceof Reader) {
				return SReader.create((Reader)o);
			}
			if( o instanceof Ref) {
				return SRef.create((Ref)o);
			}
			if( o instanceof RowId) {
				return SRowId.create((RowId)o);
			}
			if( o instanceof Savepoint) {
				return SSavepoint.create((Savepoint)o);
			}
			if( o instanceof SQLXML) {
				return SSQLXML.create((SQLXML)o);
			}
			if( o instanceof Struct) {
				return SStruct.create((Struct)o);
			}
			if( o instanceof Writer) {
				return SWriter.create((Writer)o);
			}
			throw new SQLException(MessageFormat.format("Internal error: Object of class {0} is not a known ISerializableObject",o.getClass()));
			//throw new SQLException(StringUtil.format("Internal error: Object of class {0} is not a known ISerializableObject",o.getClass()));
		}
		return null;
	}
	
	private static final long serialVersionUID = 1L;

	public SerializableObject() {
	}
	

    public static SQLException newSQLException(Throwable t) {
    	SQLException e = new SQLException();
    	e.initCause(t);
    	return e;
    }
    
    protected RuntimeException notImplementedException() {
    	return new RuntimeException("Method not implemented");
    }	
    
    protected void throwNotImplementedException() throws SQLException, RemoteException {
    	throw new SQLException("Method not implemented");
    }	
}
 public class DomSQLResultSet implements ResultSet {
    
    private DomSQLStatement stmt;

    private boolean closed;
    
    private int columnCount;
    private String[] colNames;

    private int fetchSize;
    private int fetchDirection;
    
    private int currentRow;
    private int currentCol; 
    
    private boolean closeStatementOnClose;

    public DomSQLResultSet(DomSQLStatement stmt,int columnCount, boolean empty) {
        this.stmt = stmt;
        this.columnCount = columnCount;
        this.fetchSize = stmt.getFetchSize();
        this.fetchDirection = stmt.getFetchDirection();
        this.currentRow = empty ? 0 : 1;
    }

    public DomSQLStatement getStatement() {
        return stmt;
    }

    public DomSQLResultSetMetaData getMetaData() throws SQLException {
        return new DomSQLResultSetMetaData(getHstmt());
    }

    public int getColumnCount() throws SQLException {
        return columnCount;
    }


    public DomSQLConnection getConnection() {
        return getStatement().getConnection();
    }
    
    public long getHstmt() {
        return getStatement().getHstmt();
    }
    
    public long getSqliteDb() {
        return getStatement().getSqliteDb();
    }
    
    public boolean isCloseStatementOnClose() {
        return closeStatementOnClose;
    }

    public void setCloseStatementOnClose(boolean closeStatementOnClose) {
        this.closeStatementOnClose = closeStatementOnClose;
    }
    
    

    // INTERNAL FUNCTIONS ///////////////////////////////////////////

    private void checkOpen() throws SQLException {
        if(closed) {
            throw DomSQLException.create(null,"The ResultSet is closed");
        }
    }

    public int jdbcToSqliteCol(int col, boolean store) throws SQLException {
        if(col<1 || col>columnCount) {
            throw DomSQLException.create(null,"Invalid column index {0}",col);
        }
        if(store) {
            currentCol = col;
        }
        return --col;
    }

    public int jdbcToSqliteCol(int col) throws SQLException {
        return jdbcToSqliteCol(col,true);
    }

    
    // ResultSet Functions //////////////////////////////////////////

    public boolean isClosed() throws SQLException {
        return closed;
    }

    public void close() throws SQLException {
        // Close the result set
        if(!closed) {
            release();
            if(stmt!=null) {
                if(closeStatementOnClose) {
                    stmt.close();
                } else {
                    stmt.resetStatement();
                }
                stmt = null;
            }
        }
    }
    public void release() throws SQLException {
        // Close the result set
        if(!closed) {
            closed = true;
            colNames = null;
            currentRow = 1;
            currentCol = -1;
        }
    }

    // But sure that the columns are in the range 1...n
    public int findColumn(String col) throws SQLException {
        checkOpen();
        if(colNames==null) {
            colNames = new String[columnCount];
            for(int i=0; i<columnCount; i++) {
               colNames[i] = SQLite.columnName(getHstmt(), i);
            }
        }
        for(int i=0; i<colNames.length; i++) {
            if(col.equalsIgnoreCase(colNames[i])) {
                return i+1;
            }
        }
        throw DomSQLException.create(null,"Column {0} is unknown", col);
    }

    public boolean next() throws SQLException {
        // The result set had been close, or is empty
        if(closed||currentRow==0) {
            return false;
        }
        currentCol = -1;

        // first row is loaded by execute(), so do not step() again
        if (currentRow == 1) {
            currentRow++;
            return true;
        }

        // check if we are row limited by the statement or the ResultSet
        int maxRows = stmt.getMaxRows();
        if (maxRows != 0 && currentRow > maxRows) {
            return false;
        }

        // do the real work
        switch (SQLite.step(getHstmt())) {
            case SQLite.SQLITE_DONE: {
                close();
                return false;
            }
            case SQLite.SQLITE_ROW: {
                currentRow++;
                return true;
            }
            case SQLite.SQLITE_BUSY: {
                throw DomSQLException.create(null,"Database is locked");
            }
            default: {
                getConnection().throwex();
                return false;
            }
        }
    }

    public int getType() throws SQLException {
        return TYPE_FORWARD_ONLY;
    }

    public int getFetchSize() throws SQLException {
        return fetchSize;
    }

    public void setFetchSize(int fetchSize) throws SQLException {
        if (fetchSize<0) {
            throw DomSQLException.create(null,"Invalid FetchSize value. Must be greater than 0 and less or equals to MaxRow");
        }
        this.fetchSize = fetchSize;
    }
    
    public int getFetchDirection() throws SQLException {
        return fetchDirection;
    }

    public void setFetchDirection(int fetchDirection) throws SQLException {
        if (fetchDirection!=ResultSet.FETCH_FORWARD){
            throw DomSQLException.create(null,"SQLite only supports FETCH_FORWARD");
        }
        this.fetchDirection = fetchDirection;
    }

    public boolean isAfterLast() throws SQLException {
        return closed;
    }

    public boolean isBeforeFirst() throws SQLException {
        return !closed && currentRow<=1;
    }

    public boolean isFirst() throws SQLException {
        return currentRow==2;
    }

    public boolean isLast() throws SQLException { // TODO
        throw new NotImplementedException();
    }

    protected void finalize() throws SQLException {
        close();
    }


    //@Override
    public boolean absolute(int row) throws SQLException {
    	return relative(row-currentRow);
    }

    //@Override
    public boolean relative(int rows) throws SQLException {
    	if(rows>0) {
    		while(rows>0) {
    			if(!next()) {
    				return false;
    			}
    			rows--;
    		}
    		return true;
    	}
    	throw DomSQLException.create(null, "Cannot move a cursor backwards");
    }
    
    //@Override
    public int getRow() throws SQLException {
        return currentRow;
    }

    public boolean hasRow() throws SQLException {
        // The result set had been close, or is empty
        if(closed||currentRow==0) {
            return false;
        }
        return true;
    }
    
    
    // DATA ACCESS FUNCTIONS ////////////////////////////////////////

    public boolean wasNull() throws SQLException {
        return SQLite.columnType(getHstmt(), jdbcToSqliteCol(currentCol)) == SQLite.SQLITE_NULL;
    }
    
    public boolean getBoolean(int col) throws SQLException {
        return getInt(col)!=0;
    }

    public boolean getBoolean(String col) throws SQLException {
        return getBoolean(findColumn(col));
    }

    public byte getByte(int col) throws SQLException {
        return (byte)getInt(col);
    }

    public byte getByte(String col) throws SQLException {
        return getByte(findColumn(col));
    }

    public byte[] getBytes(int col) throws SQLException {
        return SQLite.columnBlob(getHstmt(), jdbcToSqliteCol(col));
    }

    public byte[] getBytes(String col) throws SQLException {
        return getBytes(findColumn(col));
    }

    public Date getDate(int col) throws SQLException {
        if (SQLite.columnType(getHstmt(), jdbcToSqliteCol(col)) == SQLite.SQLITE_NULL) {
            return null;
        }
        long dt = SQLite.columnInt64(getHstmt(), jdbcToSqliteCol(col))*1000;
        return new Date(dt);
    }

    public Date getDate(int col, Calendar cal) throws SQLException {
        if (SQLite.columnType(getHstmt(), jdbcToSqliteCol(col)) == SQLite.SQLITE_NULL) {
            return null;
        }
        if (cal == null) {
            return getDate(col);
        }
        long dt = SQLite.columnInt64(getHstmt(), jdbcToSqliteCol(col))*1000;
        cal.setTimeInMillis(dt);
        return new Date(cal.getTime().getTime());
    }

    public Date getDate(String col) throws SQLException {
        return getDate(findColumn(col), Calendar.getInstance());
    }

    public Date getDate(String col, Calendar cal) throws SQLException {
        return getDate(findColumn(col), cal);
    }

    public double getDouble(int col) throws SQLException {
        if (SQLite.columnType(getHstmt(), jdbcToSqliteCol(col)) == SQLite.SQLITE_NULL) {
            return 0;
        }
        return SQLite.columnDouble(getHstmt(), jdbcToSqliteCol(col));
    }

    public double getDouble(String col) throws SQLException {
        return getDouble(findColumn(col));
    }

    public float getFloat(int col) throws SQLException {
        if (SQLite.columnType(getHstmt(), jdbcToSqliteCol(col)) == SQLite.SQLITE_NULL)
            return 0;
        return (float) SQLite.columnDouble(getHstmt(), jdbcToSqliteCol(col));
    }

    public float getFloat(String col) throws SQLException {
        return getFloat(findColumn(col));
    }

    public int getInt(int col) throws SQLException {
        return SQLite.columnInt(getHstmt(), jdbcToSqliteCol(col));
    }

    public int getInt(String col) throws SQLException {
        return getInt(findColumn(col));
    }

    public long getLong(int col) throws SQLException {
        return SQLite.columnInt64(getHstmt(), jdbcToSqliteCol(col));
    }

    public long getLong(String col) throws SQLException {
        return getLong(findColumn(col));
    }

    public short getShort(int col) throws SQLException {
        return (short) getInt(col);
    }

    public short getShort(String col) throws SQLException {
        return getShort(findColumn(col));
    }

    public String getString(int col) throws SQLException {
        return SQLite.columnText(getHstmt(), jdbcToSqliteCol(col));
    }

    public String getString(String col) throws SQLException {
        return getString(findColumn(col));
    }

    public Time getTime(int col) throws SQLException {
        if (SQLite.columnType(getHstmt(), jdbcToSqliteCol(col)) == SQLite.SQLITE_NULL) {
            return null;
        }
        long dt = SQLite.columnInt64(getHstmt(), jdbcToSqliteCol(col))*1000;
        return new Time(dt);
    }

    public Time getTime(int col, Calendar cal) throws SQLException {
        if (cal == null)
            return getTime(col);
        if (SQLite.columnType(getHstmt(), jdbcToSqliteCol(col)) == SQLite.SQLITE_NULL)
            return null;
        long dt = SQLite.columnInt64(getHstmt(), jdbcToSqliteCol(col))*1000;
        cal.setTimeInMillis(dt);
        return new Time(cal.getTime().getTime());
    }

    public Time getTime(String col) throws SQLException {
        return getTime(findColumn(col));
    }

    public Time getTime(String col, Calendar cal) throws SQLException {
        return getTime(findColumn(col), cal);
    }

    public Timestamp getTimestamp(int col) throws SQLException {
        if (SQLite.columnType(getHstmt(), jdbcToSqliteCol(col)) == SQLite.SQLITE_NULL) {
            return null;
        }
        long dt = SQLite.columnInt64(getHstmt(), jdbcToSqliteCol(col))*1000;
        return new Timestamp(dt);
    }

    public Timestamp getTimestamp(int col, Calendar cal) throws SQLException {
        if (cal == null) {
            return getTimestamp(col);
        }
        if (SQLite.columnType(getHstmt(), jdbcToSqliteCol(col)) == SQLite.SQLITE_NULL) {
            return null;
        }
        long dt = SQLite.columnInt64(getHstmt(), jdbcToSqliteCol(col))*1000;
        cal.setTimeInMillis(dt);
        return new Timestamp(cal.getTime().getTime());
    }

    public Timestamp getTimestamp(String col) throws SQLException {
        return getTimestamp(findColumn(col));
    }

    public Timestamp getTimestamp(String c, Calendar ca) throws SQLException {
        return getTimestamp(findColumn(c), ca);
    }

    public Object getObject(int col) throws SQLException {
        switch (SQLite.columnType(getHstmt(), jdbcToSqliteCol(col))) {
            case SQLite.SQLITE_INTEGER: {
                long val = getLong(col);
                return Long.valueOf(val);
            }
            case SQLite.SQLITE_FLOAT: {
                return Double.valueOf(getDouble(col));
            }
            case SQLite.SQLITE_BLOB: {
                return getBytes(col);
            }
            case SQLite.SQLITE_NULL: {
                return null;
            }
        }
        String s = getString(col);
        // Look if it looks like a ISO8801 date
        //   YYYY-MM-DD HH:MM:SS.SSS
        if(s.length()==23 && s.charAt(4)=='-' && s.charAt(7)=='-' && s.charAt(10)==' ' && s.charAt(13)==':'&& s.charAt(16)==':'&& s.charAt(19)=='.') {
        	int year = parseInt(s, 0, 4);
        	int month = parseInt(s, 5, 2);
        	int day = parseInt(s, 8, 2);
        	int hour = parseInt(s, 11, 2);
        	int minute = parseInt(s, 14, 2);
        	int second = parseInt(s, 17, 2);
        	int millis = parseInt(s, 20, 3);
        	return new java.sql.Timestamp(DateTime.DateStruct.createDateAsLong(year,month,day,hour,minute,second,millis));
        }
        
        return s;
    }
    private int parseInt(String s, int pos, int length) {
    	int value = 0;
    	for(int i=0; i<length; i++) {
    		value = (value*10)+(s.charAt(pos+i)-'0');
    	}
    	return value;
    }
    
    public Object getObject(String col) throws SQLException {
        return getObject(findColumn(col));
    }

    public String getCursorName() throws SQLException {
        return null;
    }

    public SQLWarning getWarnings() throws SQLException {
        return null;
    }

    public void clearWarnings() throws SQLException {
    }

    public int getConcurrency() throws SQLException {
        return CONCUR_READ_ONLY;
    }

    public boolean rowDeleted() throws SQLException {
        return false;
    }

    public boolean rowInserted() throws SQLException {
        return false;
    }

    public boolean rowUpdated() throws SQLException {
        return false;
    }

    //@Override
    public boolean isWrapperFor(Class<?> iface) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public <T> T unwrap(Class<T> iface) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void afterLast() throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void beforeFirst() throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void cancelRowUpdates() throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void deleteRow() throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public boolean first() throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public Array getArray(int columnIndex) throws SQLException {
        return DataConverter.toArray(getObject(columnIndex));
    }

    //@Override
    public Array getArray(String columnLabel) throws SQLException {
        return DataConverter.toArray(getObject(columnLabel));
    }

    //@Override
    public InputStream getAsciiStream(int columnIndex) throws SQLException {
        return DataConverter.toInputStream(getObject(columnIndex));
    }

    //@Override
    public InputStream getAsciiStream(String columnLabel) throws SQLException {
        return DataConverter.toInputStream(getObject(columnLabel));
    }

    //@Override
    public BigDecimal getBigDecimal(int columnIndex, int scale)
            throws SQLException {
        return DataConverter.toBigDecimal(getObject(columnIndex),scale);
    }

    //@Override
    public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
        return DataConverter.toBigDecimal(getObject(columnIndex));
    }

    //@Override
    public BigDecimal getBigDecimal(String columnLabel, int scale)
            throws SQLException {
        return DataConverter.toBigDecimal(getObject(columnLabel),scale);
    }

    //@Override
    public BigDecimal getBigDecimal(String columnLabel) throws SQLException {
        return DataConverter.toBigDecimal(getObject(columnLabel));
    }

    //@Override
    public InputStream getBinaryStream(int columnIndex) throws SQLException {
        return DataConverter.toInputStream(getObject(columnIndex));
    }

    //@Override
    public InputStream getBinaryStream(String columnLabel) throws SQLException {
        return DataConverter.toInputStream(getObject(columnLabel));
    }

    //@Override
    public Blob getBlob(int columnIndex) throws SQLException {
        return DataConverter.toBlob(getObject(columnIndex));
    }

    //@Override
    public Blob getBlob(String columnLabel) throws SQLException {
        return DataConverter.toBlob(getObject(columnLabel));
    }

    //@Override
    public Reader getCharacterStream(int columnIndex) throws SQLException {
        return DataConverter.toReader(getObject(columnIndex));
    }

    //@Override
    public Reader getCharacterStream(String columnLabel) throws SQLException {
        return DataConverter.toReader(getObject(columnLabel));
    }

    //@Override
    public Clob getClob(int columnIndex) throws SQLException {
        return DataConverter.toClob(getObject(columnIndex));
    }

    //@Override
    public Clob getClob(String columnLabel) throws SQLException {
        return DataConverter.toClob(getObject(columnLabel));
    }

    //@Override
    public int getHoldability() throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public Reader getNCharacterStream(int columnIndex) throws SQLException {
        return DataConverter.toReader(getObject(columnIndex));
    }

    //@Override
    public Reader getNCharacterStream(String columnLabel) throws SQLException {
        return DataConverter.toReader(getObject(columnLabel));
    }

    //@Override
    public NClob getNClob(int columnIndex) throws SQLException {
        return DataConverter.toNClob(getObject(columnIndex));
    }

    //@Override
    public NClob getNClob(String columnLabel) throws SQLException {
        return DataConverter.toNClob(getObject(columnLabel));
    }

    //@Override
    public String getNString(int columnIndex) throws SQLException {
        return DataConverter.toString(getObject(columnIndex));
    }

    //@Override
    public String getNString(String columnLabel) throws SQLException {
        return DataConverter.toString(getObject(columnLabel));
    }

    //@Override
    public Object getObject(int columnIndex, Map<String, Class<?>> map)
            throws SQLException {
    	// Ignore map...
        return getObject(columnIndex);
    }

    //@Override
    public Object getObject(String columnLabel, Map<String, Class<?>> map)
            throws SQLException {
    	// Ignore map...
        return getObject(columnLabel);
    }

    //@Override
    public Ref getRef(int columnIndex) throws SQLException {
        return DataConverter.toRef(getObject(columnIndex));
    }

    //@Override
    public Ref getRef(String columnLabel) throws SQLException {
        return DataConverter.toRef(getObject(columnLabel));
    }

    //@Override
    public RowId getRowId(int columnIndex) throws SQLException {
        return DataConverter.toRowId(getObject(columnIndex));
    }

    //@Override
    public RowId getRowId(String columnLabel) throws SQLException {
        return DataConverter.toRowId(getObject(columnLabel));
    }

    //@Override
    public SQLXML getSQLXML(int columnIndex) throws SQLException {
        return DataConverter.toSQLXML(getObject(columnIndex));
    }

    //@Override
    public SQLXML getSQLXML(String columnLabel) throws SQLException {
        return DataConverter.toSQLXML(getObject(columnLabel));
    }

    //@Override
    public InputStream getUnicodeStream(int columnIndex) throws SQLException {
        return DataConverter.toInputStream(getObject(columnIndex));
    }

    //@Override
    public InputStream getUnicodeStream(String columnLabel) throws SQLException {
        return DataConverter.toInputStream(getObject(columnLabel));
    }

    //@Override
    public URL getURL(int columnIndex) throws SQLException {
        return DataConverter.toURL(getObject(columnIndex));
    }

    //@Override
    public URL getURL(String columnLabel) throws SQLException {
        return DataConverter.toURL(getObject(columnLabel));
    }

    //@Override
    public void insertRow() throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public boolean last() throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void moveToCurrentRow() throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void moveToInsertRow() throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public boolean previous() throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void refreshRow() throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateArray(int columnIndex, Array x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateArray(String columnLabel, Array x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateAsciiStream(int columnIndex, InputStream x, int length)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateAsciiStream(int columnIndex, InputStream x, long length)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateAsciiStream(int columnIndex, InputStream x)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateAsciiStream(String columnLabel, InputStream x, int length)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateAsciiStream(String columnLabel, InputStream x, long length)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateAsciiStream(String columnLabel, InputStream x)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateBigDecimal(int columnIndex, BigDecimal x)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateBigDecimal(String columnLabel, BigDecimal x)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateBinaryStream(int columnIndex, InputStream x, int length)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateBinaryStream(int columnIndex, InputStream x, long length)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateBinaryStream(int columnIndex, InputStream x)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateBinaryStream(String columnLabel, InputStream x, int length)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateBinaryStream(String columnLabel, InputStream x,
            long length) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateBinaryStream(String columnLabel, InputStream x)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateBlob(int columnIndex, Blob x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateBlob(int columnIndex, InputStream inputStream, long length)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateBlob(int columnIndex, InputStream inputStream)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateBlob(String columnLabel, Blob x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateBlob(String columnLabel, InputStream inputStream,
            long length) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateBlob(String columnLabel, InputStream inputStream)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateBoolean(int columnIndex, boolean x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateBoolean(String columnLabel, boolean x)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateByte(int columnIndex, byte x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateByte(String columnLabel, byte x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateBytes(int columnIndex, byte[] x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateBytes(String columnLabel, byte[] x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateCharacterStream(int columnIndex, Reader x, int length)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateCharacterStream(int columnIndex, Reader x, long length)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateCharacterStream(int columnIndex, Reader x)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateCharacterStream(String columnLabel, Reader reader,
            int length) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateCharacterStream(String columnLabel, Reader reader,
            long length) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateCharacterStream(String columnLabel, Reader reader)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateClob(int columnIndex, Clob x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateClob(int columnIndex, Reader reader, long length)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateClob(int columnIndex, Reader reader) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateClob(String columnLabel, Clob x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateClob(String columnLabel, Reader reader, long length)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateClob(String columnLabel, Reader reader)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateDate(int columnIndex, Date x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateDate(String columnLabel, Date x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateDouble(int columnIndex, double x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateDouble(String columnLabel, double x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateFloat(int columnIndex, float x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateFloat(String columnLabel, float x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateInt(int columnIndex, int x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateInt(String columnLabel, int x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateLong(int columnIndex, long x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateLong(String columnLabel, long x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateNCharacterStream(int columnIndex, Reader x, long length)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateNCharacterStream(int columnIndex, Reader x)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateNCharacterStream(String columnLabel, Reader reader,
            long length) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateNCharacterStream(String columnLabel, Reader reader)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateNClob(int columnIndex, NClob clob) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateNClob(int columnIndex, Reader reader, long length)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateNClob(int columnIndex, Reader reader) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateNClob(String columnLabel, NClob clob) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateNClob(String columnLabel, Reader reader, long length)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateNClob(String columnLabel, Reader reader)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateNString(int columnIndex, String string)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateNString(String columnLabel, String string)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateNull(int columnIndex) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateNull(String columnLabel) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateObject(int columnIndex, Object x, int scaleOrLength)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateObject(int columnIndex, Object x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateObject(String columnLabel, Object x, int scaleOrLength)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateObject(String columnLabel, Object x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateRef(int columnIndex, Ref x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateRef(String columnLabel, Ref x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateRow() throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateRowId(int columnIndex, RowId x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateRowId(String columnLabel, RowId x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateShort(int columnIndex, short x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateShort(String columnLabel, short x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateSQLXML(int columnIndex, SQLXML xmlObject)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateSQLXML(String columnLabel, SQLXML xmlObject)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateString(int columnIndex, String x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateString(String columnLabel, String x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateTime(int columnIndex, Time x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateTime(String columnLabel, Time x) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateTimestamp(int columnIndex, Timestamp x)
            throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public void updateTimestamp(String columnLabel, Timestamp x)
            throws SQLException {
        throw new NotImplementedException();
    }
}
 public class DomSQLResultSetMetaData implements ResultSetMetaData {
    
    private long htsmt;

    public DomSQLResultSetMetaData(long htsmt) {
        this.htsmt = htsmt;
    }
    
    public long getHstmt() {
    	return htsmt;
    }
    
    public int jdbcToSqliteCol(int col) throws SQLException {
        return --col;
    }
    
    // ResultSetMetaData Functions //////////////////////////////////

    public String getCatalogName(int col) throws SQLException {
        int sqliteCol = jdbcToSqliteCol(col);
        return SQLite.columnTableName(getHstmt(), sqliteCol);
    }

    public String getColumnClassName(int col) throws SQLException {
        int sqliteCol = jdbcToSqliteCol(col);
        switch (SQLite.columnType(getHstmt(), sqliteCol)) {
            case SQLite.SQLITE_INTEGER:
                return "java.lang.Integer";
            case SQLite.SQLITE_FLOAT:
                return "java.lang.Double";
            case SQLite.SQLITE_BLOB:
                return "java.lang.Object";
            case SQLite.SQLITE_NULL:
                return "java.lang.Object";
            //case SQLite.SQLITE_TEXT:
        }
        return "java.lang.String";
    }

    public int getColumnCount() throws SQLException {
        int nCol = SQLite.columnCount(getHstmt()); 
        return nCol;
    }

    public int getColumnDisplaySize(int col) throws SQLException {
        int sqliteCol = jdbcToSqliteCol(col);
        switch (SQLite.columnType(getHstmt(), sqliteCol)) {
            case SQLite.SQLITE_NULL:
                return 1;
            case SQLite.SQLITE_INTEGER:
                return 15;
            case SQLite.SQLITE_FLOAT:
                return 22;
        }
        return Integer.MAX_VALUE;
    }


    public String getColumnName(int col) throws SQLException {
        int sqliteCol = jdbcToSqliteCol(col);
        return SQLite.columnName(getHstmt(), sqliteCol);
    }

    public String getColumnLabel(int col) throws SQLException {
        return getColumnName(col);
    }

    public int getColumnType(int col) throws SQLException {
        int sqliteCol = jdbcToSqliteCol(col);
        switch (SQLite.columnType(getHstmt(), sqliteCol)) {
            case SQLite.SQLITE_NULL:
                return Types.NULL;
            case SQLite.SQLITE_INTEGER:
                return Types.INTEGER;
            case SQLite.SQLITE_FLOAT:
                return Types.DOUBLE;
            case SQLite.SQLITE_BLOB:
                return Types.BLOB;
            //case SQLite.SQLITE_TEXT:
        }
        return Types.VARCHAR;
    }

    public String getColumnTypeName(int col) throws SQLException {
        int sqliteCol = jdbcToSqliteCol(col);
        switch (SQLite.columnType(getHstmt(), sqliteCol)) {
            case SQLite.SQLITE_NULL:
                return "NULL"; // Shouldn't this be text???
            case SQLite.SQLITE_INTEGER:
                return "INTEGER";
            case SQLite.SQLITE_FLOAT:
                return "FLOAT";
            case SQLite.SQLITE_BLOB:
                return "BLOB";
            //case SQLite.SQLITE_TEXT:
        }
        return "TEXT";
    }

    public int getPrecision(int col) throws SQLException {
        int sqliteCol = jdbcToSqliteCol(col);
        switch (SQLite.columnType(getHstmt(), sqliteCol)) {
            case SQLite.SQLITE_INTEGER:
                return 8;
            case SQLite.SQLITE_FLOAT:
                return 15;
        }
        return 0;
    }

    public int getScale(int col) throws SQLException {
        return 0;
    }

    public String getSchemaName(int col) throws SQLException {
        return "";
    }

    public String getTableName(int col) throws SQLException {
        int sqliteCol = jdbcToSqliteCol(col);
        return SQLite.columnTableName(getHstmt(), sqliteCol);
    }

    public int isNullable(int col) throws SQLException {
        return columnNullable;
    }

    public boolean isAutoIncrement(int col) throws SQLException {
        return false;
    }

    public boolean isCaseSensitive(int col) throws SQLException {
        return true;
    }

    public boolean isCurrency(int col) throws SQLException {
        return false;
    }

    public boolean isDefinitelyWritable(int col) throws SQLException {
        return true;
    } // FIXME: check db file constraints?

    public boolean isReadOnly(int col) throws SQLException {
        return false;
    }

    public boolean isSearchable(int col) throws SQLException {
        return true;
    }

    public boolean isSigned(int col) throws SQLException {
        return false;
    }

    public boolean isWritable(int col) throws SQLException {
        return true;
    }


    //@Override
    public boolean isWrapperFor(Class<?> iface) throws SQLException {
        throw new NotImplementedException();
    }

    //@Override
    public <T> T unwrap(Class<T> iface) throws SQLException {
        throw new NotImplementedException();
    }
}

import java.math.BigDecimal;
import java.net.URL;
import java.rmi.RemoteException;
import java.sql.Date;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Map;
import com.ibm.domino.domsql.remote.transport.IResultSet;
import com.ibm.domino.domsql.remote.transport.SArray;
import com.ibm.domino.domsql.remote.transport.SBlob;
import com.ibm.domino.domsql.remote.transport.SClob;
import com.ibm.domino.domsql.remote.transport.SInputStream;
import com.ibm.domino.domsql.remote.transport.SNClob;
import com.ibm.domino.domsql.remote.transport.SReader;
import com.ibm.domino.domsql.remote.transport.SRef;
import com.ibm.domino.domsql.remote.transport.SRowId;
import com.ibm.domino.domsql.remote.transport.SSQLXML;
import com.ibm.domino.domsql.remote.transport.SerializableObject;
import com.ibm.domino.domsql.sqlite.driver.jdbc.DomSQLResultSet;
import com.ibm.domino.domsql.sqlite.driver.jdbc.DomSQLResultSetMetaData;

    public boolean wasNull() throws SQLException, RemoteException {
        initContext();
        try {
            return wrap(resultSet.wasNull());
        } finally {
            termContext();
        }
    }

    public SRowId getRowId(int columnIndex) throws SQLException, RemoteException {
        initContext();
        try {
            return wrap(SRowId.create(resultSet.getRowId(columnIndex)));
        } finally {
            termContext();
        }
    }

    public SRowId getRowId(String columnLabel) throws SQLException, RemoteException {
        initContext();
        try {
            return wrap(SRowId.create(resultSet.getRowId(columnLabel)));
        } finally {
            termContext();
        }
    }

    public void updateRowId(int columnIndex, SRowId x) throws SQLException, RemoteException {
        initContext();
        try {
            resultSet.updateRowId(columnIndex, x);
        } finally {
            termContext();
        }
    }

    public void updateRowId(String columnLabel, SRowId x) throws SQLException, RemoteException {
        initContext();
        try {
            resultSet.updateRowId(columnLabel, x);
        } finally {
            termContext();
        }
    }

    public int getHoldability() throws SQLException, RemoteException {
        initContext();
        try {
            return wrap(resultSet.getHoldability());
        } finally {
            termContext();
        }
    }

    public boolean isClosed() throws SQLException, RemoteException {
        initContext();
        try {
            return wrap(resultSet.isClosed());
        } finally {
            termContext();
        }
    }

    public void updateNString(int columnIndex, String nString)
            throws SQLException, RemoteException {
        initContext();
        try {
            resultSet.updateNString(columnIndex, nString);
        } finally {
            termContext();
        }
    }

    public void updateNString(String columnLabel, String nString)
            throws SQLException, RemoteException {
        initContext();
        try {
            resultSet.updateNString(columnLabel, nString);
        } finally {
            termContext();
        }
    }

    public void updateNClob(int columnIndex, SNClob nClob) throws SQLException, RemoteException {
        initContext();
        try {
            resultSet.updateNClob(columnIndex, nClob);
        } finally {
            termContext();
        }
    }

    public void updateNClob(String columnLabel, SNClob nClob)
            throws SQLException, RemoteException {
        initContext();
        try {
            resultSet.updateNClob(columnLabel, nClob);
        } finally {
            termContext();
        }
    }

    public SNClob getNClob(int columnIndex) throws SQLException, RemoteException {
        initContext();
        try {
            return wrap(SNClob.create(resultSet.getNClob(columnIndex)));
        } finally {
            termContext();
        }
    }

    public SNClob getNClob(String columnLabel) throws SQLException, RemoteException {
        initContext();
        try {
            return wrap(SNClob.create(resultSet.getNClob(columnLabel)));
        } finally {
            termContext();
        }
    }


    public SSQLXML getSQLXML(int columnIndex) throws SQLException, RemoteException {
