Why Did SQLJ Die?
Every now and then, SQLJ pops up somewhere, mostly in a very dusty/enterprisey or in an academic context.
If you give SQLJ some thought, though, it isn’t such a bad idea. It is:
- An ANSI and ISO standard
- Part of the SQL standard
- Quite easy to understand
- Quite a powerful extension to JDBC
Let’s assume that you have already decided to embed your SQL (as opposed to externalising it through a templating mechanism, hiding it with an ORM, or with stored procedures). Here are a couple of reasons why SQLJ is not an optimal solution for embedding SQL:
While Pro*C worked well for C and C++ in the 90s, Java really took off in the early 2000’s. With Java, there were also an increasing number of powerful IDEs such as Eclipse, NetBeans, JBuilder, and others. Java preprocessors and IDEs have never become friends, though, as parsing one language is hard enough. Parsing (and providing tooling) for two languages is much harder.
In fact, SQLJ made the surrounding Java code type-unsafe as IDEs and compilers couldn’t process .sqlj files before they had been pre-processed.
There was a time when people started thinking that SQL itself was going to be dead. First, they did so with the advent of ORMs, then they did so with the advent of NoSQL. People thought that the DBA is dead. Again.
Well, this has been proven to be wrong a couple of times, but certainly not because of SQLJ.
In the late 2000’s, there had now been typesafe alternatives to SQLJ, such as jOOQ in Java, or LINQ-to.SQL in .NET, which leverage IDE features such as syntax autocompletion. By being internal domain-specific languages / query DSLs, these APIs not only bring typesafety to embedded SQL, but they also allow for dynamic SQL building, which SQLJ doesn’t support.
While embedding SQL into other languages is a useful thing, SQLJ never solved this problem adequately. Hence, R.I.P., SQLJ
That was awesome, right? Share it with your friends!
- 1,055,093 hits
- RT @ygrenzinger: Hibernate as usual is a pain in the ass. Funny thing I have just a JOOq licence :) 1 day ago
- This is it. Finally, Java annotations have the fan page they deserve: buff.ly/1upqlVf. Share your beautiful @Love with annotations 1 day ago
Get Back in Control of Your SQL
Top Posts & Pages
- How to Translate SQL GROUP BY and Aggregations to Java 8
- 10 Common Mistakes Java Developers Make when Writing SQL
- SQL Trick: row_number() is to SELECT what dense_rank() is to SELECT DISTINCT
- 10 Subtle Best Practices when Coding Java
- 10 More Common Mistakes Java Developers Make when Writing SQL
- Does Java 8 Still Need LINQ? Or is it Better than LINQ?
- The 10 Most Popular DB Engines (SQL and NoSQL)
- Java 8 Friday: No More Need for ORMs
- The Open Source Bikeshed.
- Using SQL Injection Vulnerabilities to Dump Your Database
- How to Translate SQL GROUP BY and Aggregations to Java 8 January 23, 2015
- jOOQ Newsletter: January 21, 2015 – Groovy and Open Source – jOOQ and the strong Swiss Franc January 21, 2015
- Open Source Doesn’t Need More Support. It Needs Better Business Models January 21, 2015
- Suis-je Groovy? No! What Pivotal’s Decision Means for Open Source Software January 19, 2015
- Using Java 8 to Prevent Excessively Wide Logs January 19, 2015
- Infinite Loops. Or: Anything that Can Possibly Go Wrong, Does. January 16, 2015
- Transform Your SQL Data into Charts Using jOOQ and JavaFX January 8, 2015
- How to Emulate the MEDIAN() Aggregate Function Using Inverse Distribution Functions January 6, 2015
- The Awesome PostgreSQL 9.4 / SQL:2003 FILTER Clause for Aggregate Functions December 30, 2014
- Leaky Abstractions, or How to Bind Oracle DATE Correctly with Hibernate December 29, 2014