If you're working on a recent version of Optiq, schemas exist outside of connections. None of the objects in the schema (e.g. tables) should have a reference to an open connection. When you want to get data from these tables, an Optiq connection will be passed in. You can store the connection to the underlying system in the Optiq connection, or can create a connection for the duration of the scan, and make sure that you close it when the scan completes.
See for example JdbcTable.asQueryable. The Enumerator is from ResultSetEnumerable, which takes a DataSource as an argument, creates a java.sql.Connection, and calls java.sql.Connection.close() from ResultSetEnumerator.close(). While you are initializing a schema, you will probably create a short-lived connection, populate metadata, and then close the connection. JdbcSchema.computeTables is an example of this. The metadata objects (in this case instances of JdbcTable) do not keep a reference to that connection. Hope that helps. By the way, I presume you are the same Marc Prud'hommeaux who started the sqlline project many years ago. Thank you! We are still enjoying (and improving) that project. Julian On Jul 4, 2014, at 12:16 PM, Marc Prud’hommeaux <[email protected]> wrote: > Optiq Folk- > > I'm writing an Optiq adapter, modeled on the excellent optiq-csv sample. I'm > wondering when and where I should close the connection to the underlying > datasource? The connection is being created in my AbstractSchema subclass, > but there doesn't appear to be any close() or disconnect() method in there > for me to override. > > -Marc >
