[JDBC-80] Add support for generic java.sql.DatabaseMetaData use now connection management is more explicit. Created: 11/Dec/13 Updated: 12/Dec/13 Resolved: 12/Dec/13
|Reporter:||Niels van Klaveren||Assignee:||Sean Corfield|
In clojure.java.jdbc 0.2.3 it was easy to call methods on the connection, like .getDatabaseMetaData.
Now connection management has changed, and finding, reaching and keeping connections (and accompanying DatabaseMetaData) is a lot harder.
It would be good to have two new functions that would give access to all database metadata information in a minimalistic way, and keeps connection management in line with the new clojure.java.jdbc 0.3.0 ideals.
The first is a function that gets / sets up a connection by the new connection rules (find-, get-, add-connection), and provides a local binding for the DatabaseMetaData object resulting from calling .getDatabaseMetaData on that connection.
The second is a function (or enhancement of result-set-seq) that calls result-set-seq if the argument is (instance? java.sql.ResultSet) or else the argument itself; this is because metadata method calls can either give back a resultset that needs to be clojurized (f.i. .getTables)or an object by themselves (f.i. .getDriverName). Let's call it meta-result as an example.
That would make things like the following possible:
As far as I can see that's a pretty minimalistic set of functions that unlocks all DatabaseMetaData possibilities. Also, because it integrates with the new connection rules, it would integrate nicely with transactions, in case of queries that are dynamically generated on metadata within the same transaction.
|Comment by Sean Corfield [ 11/Dec/13 11:00 AM ]|
Nice suggestion. Thanx. with-db-metadata is probably more in line with the current naming and perhaps metadata-result to tie back to that name, rather than cause any confusion with Clojure's built-in meta?
|Comment by Niels van Klaveren [ 11/Dec/13 11:27 AM ]|
Glad you like it. For my use it was the only basic option still missing from clojure.java.jdbc.
|Comment by Sean Corfield [ 12/Dec/13 7:56 PM ]|
Added with-db-metadata and metadata-result. Will be in RC1.