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,509,034 hits
- Did you know that the jOOQ license is a floating, developer-only license? All your servers are licensed for FREE! buff.ly/1FYkfpy 9 hours ago
- Very interesting details about how storage is implemented in an RDBMS: "How SQL UPDATE is performed in CUBRID RDBMS" buff.ly/1LHlYhb 12 hours ago
Get Back in Control of Your SQL
Top Posts & Pages
- SQL Trick: row_number() is to SELECT what dense_rank() is to SELECT DISTINCT
- Java 8 Friday: 10 Subtle Mistakes When Using the Streams API
- Do You Really Understand SQL's GROUP BY and HAVING clauses?
- 10 Subtle Best Practices when Coding Java
- We're Taking Bets: This Annotation Will Soon Show up in the JDK
- The Difference Between ROW_NUMBER(), RANK(), and DENSE_RANK()
- 10 Common Mistakes Java Developers Make when Writing SQL
- The 10 Most Popular DB Engines (SQL and NoSQL)
- Java 8 Friday: No More Need for ORMs
- Top 10 Easy Performance Optimisations in Java
- We’re Taking Bets: This Annotation Will Soon Show up in the JDK May 28, 2015
- Type Safe Queries for JPA’s Native Query API May 26, 2015
- Do Not Make This Mistake When Developing an SPI May 21, 2015
- How to Access a Method’s Result Value From the Finally Block May 19, 2015
- Use This Preference to Speed up Your Eclipse m2e Configuration May 14, 2015
- Functional Programming in Java 8 with Javaslang May 13, 2015
- Use this Neat Window Function Trick to Calculate Time Differences in a Time Series May 12, 2015
- PostgreSQL’s Best-Kept Secret, and how to Use it with jOOQ May 7, 2015
- How SQL GROUP BY Should Have Been Designed – Like Neo4j’s Implicit GROUP BY May 5, 2015
- This Common API Technique is Actually an Anti-Pattern April 30, 2015