Introduction and Life Cycle
Java™ database connectivity (JDBC) is the JavaSoft specification of a standard application programming interface (API) that allows Java programs to access database management systems. The JDBC API consists of a set of interfaces and classes written in the Java programming language.
Using these standard interfaces and classes, programmers can write applications that connect to databases, send queries written in structured query language (SQL), and process the results.
Since JDBC is a standard specification, one Java program that uses the JDBC API can connect to any database management system (DBMS), as long as a driver exists for that particular DBMS.
A JDBC program comprises the following FIVE steps:
STEP 1: Allocate a
Connectionobject, for connecting to the database server.STEP 2: Allocate a
Statementobject, under theConnectioncreated earlier, for holding a SQL command.STEP 3: Write a SQL query and execute the query, via the
StatementandConnectioncreated.STEP 4: Process the query result as
ResultSet. TheResultSetonly for Select Query.STEP 5: Close the
StatementandConnectionto free up the resources.
Last updated
