H2 database and plugins

I’m not much familiar with H2 at all actually. I may have seen it as an options in some plugins, but know nothing of it. I’d think if someone were willing to do a post about proper queries, it may be best to start out with different database types (how they work, how they’re accessed, and the pros/cons vs other libraries). Maybe even cover some libraries used to access various types. I think I’d read it. Maybe even a good thing to bookmark for later if I needed to pick up SQL or database stuff again.

Maybe not about proper queries but I might do a post about how to use the different databases available in Java. For the most part they can all be used with JDBC in a similar syntax shown in my code example further up in this thread.

1 Like

Maybe if someone else wrote about the rest they could just link to your post about that then XD

One thing I really love about H2 is the way they describe their grammar.
(the ubiquitous select statement is here)
There’s just a really nice flow to it. Also, H2 is a self-contained package. It stores local database files. It can be pretty fussy about threads and locks though, there are at least 4 threads per connection.

1 Like

We mainly designed jOOQ for the needs of corporate environments, such as banking, logistics, insurance, supply chain management systems and the likes. Our customers value jOOQ for the performance it offers compared to popular ORMs, as you’re in full control of all the generated SQL. It does perform a little worse than JDBC, of course, as there is a certain overhead because of:

  • SQL queries being assembled as ASTs (Abstract Syntax Trees) in Java memory
  • No support for primitive types in results (because of Java generics)
  • Eager fetching of results by default (you can explicitly lazy-fetch your results, though)

If you have any concrete questions, we’re more than happy to help you on the jOOQ User Group (https://groups.google.com/d/forum/jooq-user)

Cheers,
Lukas from jOOQ

1 Like

jOOQ is a nice SQL DSL for Java with support for different flavors. However, it can’t generate table creation statements as far as I know.

Not yet, but we’re working on more DDL support.

Cheers,
Lukas from jOOQ

1 Like

Thanks for the explanation

I like Ebeans, but it is missing some features.
It does not check for missing columns nor does it generate missing tables.
Or it might jsut be me not setting it up right :stuck_out_tongue:

I would be intrested in using JOOQ

table creation statments are essential!!!
if it cant do table creation statments, then i will hate you all :smile:

IMO any type of database API does not belong in Sponge. If there is a real desire to have some sort of database API then those that are looking for one should get together, collaborate, and create a companion library.

You might want to have a look at Slick. It can both let you run your own SQL queries, or generate them for you in a very natural way.

Side note: Remember how people always told you to never use $db->query("SELECT id FROM users WHERE username='$name'") in PHP because of the security issues? Well, with Slick, sql"SELECT id FRoM users WHERE username=$name" automatically handles all of that for you.