File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes class library representing SQL statement? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "class library representing SQL statement?" Watch "class library representing SQL statement?" New topic

class library representing SQL statement?

Donal Lynch

Joined: May 02, 2002
Posts: 15
I'm looking for a library that manipulates SQL statements, something along the lines of:

It's for an application where the same data is being looked at by users with various combinations of permissions and preferences, so there's a core query that stays the same, with rows and columns added or taken away for specific invocations.
The other thing I'd like to be able to do is something like:

It's simple, it must have been done before, but my Google queries (eg "java sql") are unsuccessful. Thanks for any help.
Michael Zalewski
Ranch Hand

Joined: Apr 23, 2002
Posts: 168
Check out Torque Criteria
Donal Lynch

Joined: May 02, 2002
Posts: 15
Hello again,
Thanks Michael for the pointer to Torque, which I tried and liked. The best way of summarising its convenience is that Torque is to accessing databases as RMI is to accessing services over the network: it compiles database peer classes that represent information held in a database, saving the tedium of coding accessor methods and data conversions by hand, and hiding the conceptual mismatches of objects communicating with things that aren't objects.
However I have a doubt about whether Torque is appropriate for my application, which doesn't do much more than extracting tabular information from a database and displaying the same tabular information to the user. I don't know if it's worth converting each row in a table to an object of a specially compiled class when this object doesn't encapsulate any business functionality and doesn't participate in any interactions apart from getXxx and setXxx.
The small amount of intelligence in my application seems to be focussed on constructing queries and views of tabular data, so I'm looking for a class library that represents those concepts rather than hiding them. The Torque Criteria class looks like what I want, except I can't see any way of using it except by passing it to a Torque-generated database peer object, which I don't want.
Lukas Eder
Ranch Hand

Joined: Jul 22, 2013
Posts: 48

Back in 2002, there weren't many libraries that elegantly implemented SQL building in a typesafe way. Today, you have a broad choice. Just to name a few:

  • jOOQ:
  • JaQu:
  • iciql: (a friendly fork of JaQu)
  • Quaere:
  • Jequel: (in maintenance mode, I think)
  • Squiggle: (in maintenance mode, I think)

  • Apart from the above, there is always

  • Hibernate/JPA CriteriaQuery

  • When Java and SQL work together, great software can evolve. That's why we have created jOOQ. Follow me on
    I agree. Here's the link:
    subject: class library representing SQL statement?
    It's not a secret anymore!