Java JDBC - Team-5/UserGuides GitHub Wiki
#Java JDBC User Guide ###JDBC helps you to write Java applications that manage these three programming activities:
1. Connect to a data source, like a database
2. Send queries and update statements to the database
3. Retrieve and process the results received from the database in answer
to your query
###JDBC includes four components:
1. The JDBC™ API provides programmatic access to relational data from the Java™ programming language.
Using the JDBC API, applications can execute SQL statements, retrieve results, and propagate changes
back to an underlying data source. The JDBC API can also interact with multiple data sources in a
distributed, heterogeneous environment.
2. The JDBC DriverManager class defines objects which can connect Java applications to a JDBC driver.
DriverManager has traditionally been the backbone of the JDBC architecture. It is quite small and simple.
3. The JDBC driver test suite helps you to determine that JDBC drivers will run your program. These
tests are not comprehensive or exhaustive, but they do exercise many of the important features in
the JDBC API.
4. The Java Software bridge provides JDBC access via ODBC drivers. Note that you need to load ODBC
binary code onto each client machine that uses this driver. As a result, the ODBC driver is most
appropriate on a corporate network where client installations are not a major problem, or for
application server code written in Java in a three-tier architecture.
###Common SQL Commands Data Manipulation Language (DML)
1. SELECT — used to query and display data from a database.
The SELECT statement specifies which columns to include in the
result set. The vast majority of the SQL commands used in
applications are SELECT statements.
2. INSERT — adds new rows to a table. INSERT is used to populate
a newly created table or to add a new row (or rows) to an
already-existing table.
3. DELETE — removes a specified row or set of rows from a table.
4. UPDATE — changes an existing value in a column or group of
columns in a table.
5. CREATE TABLE — creates a table with the column names the user provides.
The user also needs to specify a type for the data in each column. Data
types vary from one RDBMS to another, so a user might need to use metadata
to establish the data types used by a particular database. CREATE TABLE is
normally used less often than the data manipulation commands because a table
is created only once, whereas adding or deleting rows or changing individual
values generally occurs more frequently.
6. DROP TABLE — deletes all rows and removes the table definition from
the database. A JDBC API implementation is required to support the DROP
TABLE command as specified by SQL92, Transitional Level. However, support
for the CASCADE and RESTRICT options of DROP TABLE is optional. In addition,
the behavior of DROP TABLE is implementation-defined when there are views or
integrity constraints defined that reference the table being dropped.
7. ALTER TABLE — adds or removes a column from a table. It also adds or
drops table constraints and alters column attributes