SQLJ is a working title for efforts to combine
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
and
SQL
Structured Query Language (SQL) (pronounced ''S-Q-L''; or alternatively as "sequel")
is a domain-specific language used to manage data, especially in a relational database management system (RDBMS). It is particularly useful in handling s ...
. It was a common effort started around 1997 by engineers from
IBM
International Business Machines Corporation (using the trademark IBM), nicknamed Big Blue, is an American Multinational corporation, multinational technology company headquartered in Armonk, New York, and present in over 175 countries. It is ...
,
Oracle
An oracle is a person or thing considered to provide insight, wise counsel or prophetic predictions, most notably including precognition of the future, inspired by deities. If done through occultic means, it is a form of divination.
Descript ...
,
Compaq
Compaq Computer Corporation was an American information technology, information technology company founded in 1982 that developed, sold, and supported computers and related products and services. Compaq produced some of the first IBM PC compati ...
,
Informix
Informix is a product family within IBM's Information Management division that is centered on several relational database management system (RDBMS) and multi-model database offerings. The Informix products were originally developed by Inform ...
,
Sybase
Sybase, Inc. was an enterprise software and services company. The company produced software relating to relational databases, with facilities located in California and Massachusetts. Sybase was acquired by SAP in 2010; SAP ceased using the Syba ...
,
Cloudscape and
Sun Microsystems
Sun Microsystems, Inc., often known as Sun for short, was an American technology company that existed from 1982 to 2010 which developed and sold computers, computer components, software, and information technology services. Sun contributed sig ...
.
It consists of the three parts: 0, 1 and 2. Part 0 describes the embedding of SQL statements into Java programs. SQLJ part 0 is the basis for part 10 of the
SQL:1999 standard, aka
SQL Object Language Bindings (SQL/OLB).
SQLJ parts 1 and 2 describes the converse possibility to use Java classes (routines and types) from SQL statements. Parts 1 and 2 are the basis for part 13 of the SQL standard,
SQL Routines and Types Using the Java Programming Language (SQL/JRT).
"SQLJ" is commonly used to refer to just SQLJ part 0, usually when it is contrasted with other means of embedding SQL in Java, like
JDBC
Java Database Connectivity (JDBC) is an application programming interface (API) for the Java (programming language), Java programming language which defines how a client may access a database. It is a Java-based data access technology used for Java ...
.
ANSI and ISO standards
* SQLJ part 0:
ANSI
The American National Standards Institute (ANSI ) is a private nonprofit organization that oversees the development of voluntary consensus standards for products, services, processes, systems, and personnel in the United States. The organiz ...
X3.135.10-1998, "Database Language SQL—Part 10: Object Language Bindings (SQL/OLB)"
* SQLJ part 1: ANSI
NCITS 331.1-1999, "SQLJ—Part 1: SQL Routines Using the Java Programming Language"
* SQLJ part 2: ANSI NCITS 331.2-2000, "SQLJ—Part 2: SQL Types Using the Java Programming Language"
Part 0 was updated for JDBC 2.0 compatibility and ratified by ISO in 2000. The last two parts were combined when submitted to ISO. Part 2 was substantially rewritten for the ISO submission because the ANSI version was not formal enough for a specification, being closer to the style of a
user manual
A user guide, also commonly known as a user manual, is intended to assist users in using a particular product, service or application. It is usually written by a technician, product developer, or a company's customer service staff.
Most user gu ...
. The combined version was ratified in 2002.
* ISO/IEC 9075-10:2000, ''Information technology—Database languages—SQL—Part 10: Object Language Bindings (SQL/OLB)''
* ISO/IEC 9075-13:2002, ''Information technology—Database languages—SQL—Part 13: SQL Routines and Types Using the Java Programming Language (SQL/JRT)''.
SQLJ part 0
The SQLJ part 0 specification largely originated from Oracle, who also provided the first reference implementation.
In the following SQLJ is a synonym for SQLJ part 0.
Whereas
JDBC
Java Database Connectivity (JDBC) is an application programming interface (API) for the Java (programming language), Java programming language which defines how a client may access a database. It is a Java-based data access technology used for Java ...
provides an
API
An application programming interface (API) is a connection between computers or between computer programs. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how to build ...
, SQLJ consists of a
language
Language is a structured system of communication that consists of grammar and vocabulary. It is the primary means by which humans convey meaning, both in spoken and signed language, signed forms, and may also be conveyed through writing syste ...
extension. Thus programs containing SQLJ must be run through a
preprocessor
In computer science, a preprocessor (or precompiler) is a Computer program, program that processes its input data to produce output that is used as input in another program. The output is said to be a preprocessed form of the input data, which i ...
(the SQLJ translator) before they can be compiled.
Advantages
Some advantages of SQLJ over JDBC include:
* SQLJ commands tend to be shorter than equivalent JDBC programs.
* SQL syntax can be checked at compile time. The returned query results can also be checked strictly.
* Preprocessor might generate static SQL which performs better than dynamic SQL because query plan is created on program compile time, stored in database and reused at runtime. Static SQL can guarantee access plan stability. IBM DB2 supports static SQL use in SQLJ programs.
Disadvantages
* SQLJ requires a preprocessing step.
* Many
IDEs do not have SQLJ support.
* SQLJ lacks support for most of the common persistence frameworks, such as
Hibernate
Hibernation is a state of minimal activity and metabolic reduction entered by some animal species. Hibernation is a seasonal heterothermy characterized by low body-temperature, slow breathing and heart-rate, and low metabolic rate. It is most ...
.
* Oracle 18c (12.2) has desupported SQLJ in the database.
Examples
The following examples compare SQLJ syntax with JDBC usage.
See also
*
Embedded SQL
Embedded SQL is a method of combining the computing power of a programming language and the database manipulation capabilities of SQL. Embedded SQL statements are SQL statements written inline with the program source code, of the host language. T ...
*
Language Integrated Query
Language Integrated Query (LINQ, pronounced "link") is a Microsoft .NET Framework component that adds native data querying capabilities to .NET languages, originally released as a major part of .NET Framework 3.5 in 2007.
LINQ extends the ...
(LINQ)
References
Further reading
* Connie Tsui
Considering SQLJ for Your DB2 V8 Java Applications IBM developerworks, 13 Feb 2003
* Owen Cline
Develop your applications using SQLJ IBM developerworks, 16 Dec 2004
* {{cite book, author=Jason Price, title=Java Programming With Oracle SQLJ, year=2001, publisher=O'Reilly Media, isbn=978-0-596-00087-5, url-access=registration, url=https://archive.org/details/javaprogrammingw00jaso
External links
Oracle SQLJ Developers Guide
Database Connectivity
Database APIs
SQL data access