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
Everytime you read an excellent article and don't share it, god kills a kitten!
- 1,400,388 hits
- RT @javacodegeeks: #jOOQ – Type safe DB querying - FREE #Java Code Geeks Academy course! buff.ly/1OP8DUC 12 hours ago
- Brains of the #jOOQ community, we summon ye. Awesome feature idea: buff.ly/1ONn4IR But how to implement it? With annotations? 2 days ago
Get Back in Control of Your SQL
Top Posts & Pages
- 10 More Common Mistakes Java Developers Make when Writing SQL
- Java 8 Friday: 10 Subtle Mistakes When Using the Streams API
- SQL Trick: row_number() is to SELECT what dense_rank() is to SELECT DISTINCT
- 10 Subtle Best Practices when Coding Java
- How JPA 2.1 has become the new EJB 2.0
- The 10 Most Popular DB Engines (SQL and NoSQL)
- Do You Really Understand SQL's GROUP BY and HAVING clauses?
- Using SQL Injection Vulnerabilities to Dump Your Database
- Top 10 Easy Performance Optimisations in Java
- 10 Common Mistakes Java Developers Make when Writing SQL
- Is Your Eclipse Running a Bit Slow? Just Use This Simple Trick! April 21, 2015
- How JPA 2.1 has become the new EJB 2.0 April 15, 2015
- jOOQ Tuesdays: Vlad Mihalcea Gives Deep Insight into SQL and Hibernate April 14, 2015
- It’s the Little Things: The PL/SQL NULL Statement, and why Every Language Should have One April 13, 2015
- How to FlatMap a JDBC ResultSet with Java 8? April 9, 2015
- How to Avoid the Dreaded Dead Lock when Pessimistic Locking – And some Awesome Java 8 Usage! April 7, 2015
- How to Use Java 8 Streams to Swiftly Replace Elements in a List April 2, 2015
- Don’t be Fooled by Generics and Backwards-Compatibility. Use Generic Generic Types April 1, 2015
- Hack up a Simple JDBC ResultSet Cache Using jOOQ’s MockDataProvider March 26, 2015
- jOOQ vs. Hibernate: When to Choose Which March 24, 2015