Understanding SQL & Java Together: A Guide to SQLJ, JDBC, and Related Technologies

In this chapter, we're going to review the database language SQL for the benefit of readers who are Java programmers but don't have extensive (or, perhaps, any) experience with SQL or with database systems. We'll start off with an overview of SQL, including its purpose and use and its place in information technology life, and then we'll give you a number of examples of SQL statements with a brief analysis of some of them.
We'll also present various reasons why a Java programmer needs to know something about SQL, including a few paragraphs that compare and contrast SQL with object-oriented database systems. One important component of using SQL and Java together involves understanding the mappings between SQL's data types and Java's types and classes. Because of the fundamental importance of this subject, we'll include a significant amount of information on it.
As you may know already, SQL is rarely used alone to write applications (although the more modern facilities in the SQL standard permit application designers to build more and more of their systems purely in SQL when appropriate). Instead, it is almost always combined with code in one or more other programming languages, with facilities in each language used to satisfy requirements for which they are best suited. There are several ways in which traditional programming languages and SQL are used together:
Embedded SQL, in which SQL statements are embedded in an otherwise ordinary programming language; these statements are executed by invoking database functionality whenever they are...