create table

14 views
Skip to first unread message

pco...@inhancetechnology.com

unread,
Jun 9, 2016, 6:22:26 AM6/9/16
to jOOQ User Group
How do I execute a createTableIfNotExists correctly

Calling the method is not creating the table.  Is there an additional step to execute the statement?

DSLContext create = DSL.using(conn, SQLDialect.MYSQL);


logger.info("CREATING TABLES");

create.createTableIfNotExists(Keystore.KEYSTORE);

Lukas Eder

unread,
Jun 9, 2016, 6:31:30 AM6/9/16
to jooq...@googlegroups.com
2016-06-09 13:04 GMT+03:00 <pco...@inhancetechnology.com>:
How do I execute a createTableIfNotExists correctly

Calling the method is not creating the table.  Is there an additional step to execute the statement?

The answer is in your question :)
 

DSLContext create = DSL.using(conn, SQLDialect.MYSQL);


logger.info("CREATING TABLES");

create.createTableIfNotExists(Keystore.KEYSTORE);

Append ".execute()" Of course, you will need to first append also some columns.
Some examples can be found here in the manual:

Patrick Conway

unread,
Jun 21, 2016, 11:24:32 AM6/21/16
to jOOQ User Group
DOH!!!

Well that was embarassing :)

Lukas Eder

unread,
Jun 21, 2016, 6:07:58 PM6/21/16
to jooq...@googlegroups.com
Don't worry, it happens to the best :)

I wish there was a simpler way to trigger execution. Like in PL/SQL, where execution is "automatic" as soon as the parser hits the semicolon. But unfortunately, that's not possible in an internal DSL. With fetch() it's more obvious as you want to use the result, unlike execute()'s returned row count, which is mostly useless.

Of course, you could switch to "external execution" via DSLContext.execute(Query), but that would remove fluency, I suspect.

Oh well...

--
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 jooq-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages