Hi Lance,

While jOOQ-Meta is a module that has been rendered independent of
jOOQ-Codegen, its main purpose is still to be consumed be the code
generator. Nonetheless, you might find some useful features in there.
Comments to your questions inline

2013/8/14 uklance <[email protected]>

> I'm creating an open source tool which needs to:
> 1. Extract a schema from a JDBC connection
>
2. Execute SQL to create a schema from scratch
>
> It seems that jOOQ might have solved this problem in a database agnostic
> way... I've had a bit of a look at jOOQ-meta and it seems to be what I want.
>
> So, a couple of questions:
> 1. I can see the Database and SQLDialect classes which seem to be a
> generic way to access meta data and generate SQL. Are there any pieces of
> code I can look at to see the proper use for these classes? A good test
> case perhaps?
>

jOOQ utilities can extract a SQLDialect from a JDBC URL:
-
http://www.jooq.org/javadoc/latest/org/jooq/tools/jdbc/JDBCUtils.html#dialect(java.sql.Connection)
-
http://www.jooq.org/javadoc/latest/org/jooq/tools/jdbc/JDBCUtils.html#dialect(java.lang.String)


> 2. Can I use jOOQ-meta to extract the meta information from a JDBC
> connection (including tables, columns, column types, auto-increments,
> primary keys, foreign keys)
>

Yes, you can. Just instanciate the right Database object - e.g.
OracleDatabase. Some inspiration can be found here:
https://github.com/jOOQ/jOOQ/blob/master/jOOQ-codegen/src/main/java/org/jooq/util/GenerationTool.java


> 3. Can I use a jOOQ utility to create a schema based on a schema model?
>

jOOQ does not explicitly support DDL. For these things, you might find
Flyway more useful: http://flywaydb.org


> 3. Can I use a jOOQ util to generically insert into a table and retrieve
> the generated auto-increment in a database agnostic way?
>

In principle, this is possible. jOOQ emulates Postgres' INSERT .. RETURNING
clause by using JDBC's generatedKeys property, or by calling database
functions to fetch the last inserted ID.

But beware of an open issue:
https://github.com/jOOQ/jOOQ/issues/2685


> Please note that I'm creating a tool. I do not wish to generate the jOOQ
> model for a database. I want to use the generic "under the hood" utils that
> jOOQ uses.
>

Yes, many users have successfully used jOOQ in this way - i.e. without
using the code generator:
http://www.jooq.org/doc/3.1/manual/getting-started/use-cases/jooq-as-a-standalone-sql-builder

Cheers
Lukas

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to