JDBC API
Now, we will learn about the JDBC API. The JDBC API is implemented through the
JDBC driver. The JDBC Driver is a set of classes that implement the JDBC interfaces
to process JDBC calls and return result sets to a Java application. The database (orJDBC driver. The JDBC Driver is a set of classes that implement the JDBC interfaces
data store) stores the data retrieved by the application using the JDBC Driver.
The API interface is made up of 4 main interfaces:
• java.sql DriverManager
• java. sql .Connection
• java. sql. Statement
• java.sql.Resultset
• java. sql .Connection
• java. sql. Statement
• java.sql.Resultset
In addition to these, the following support interfaces are also available to the
developer:
developer:
• java.sql.Callablestatement
• java. sql. DatabaseMetaData
• java.sql.Driver
• java. sql. PreparedStatement
• java. sql .ResultSetMetaData
• java. sql. DriverPropertymfo
• java.sql.Date
• java.sql.Time
• java. sql. Timestamp
• java.sql.Types
• java. sql. Numeric
• java. sql. DatabaseMetaData
• java.sql.Driver
• java. sql. PreparedStatement
• java. sql .ResultSetMetaData
• java. sql. DriverPropertymfo
• java.sql.Date
• java.sql.Time
• java. sql. Timestamp
• java.sql.Types
• java. sql. Numeric
The main objects of the JDBC API include:
Manager can also be used to establish a connection, connecting through a
DataSource object is the preferred method.
DataSource object is the preferred method.
• A Connection object controls the connection to the database. An application
can alter the behavior of a connection by invoking the methods associated with
this object. An application uses the connection object to create statements.
can alter the behavior of a connection by invoking the methods associated with
this object. An application uses the connection object to create statements.
• Statement object are used for executing SQL queries.
Different types of JDBC SQL Statements
a) java.sql.Statement : Top most interface which provides basic methods useful for
executing SELECT, INSERT, UPDATE and DELETE SQL statements.
b) java.sql.PreparedStatement : An enhanced verion of java.sql.Statement which
allows precompiled queries with parameters. A PreparedStatement object is used
when an application plans to specify parameters to your SQL queries. The
statement can be executed multiple times with different parameter values
specified for each execution
executing SELECT, INSERT, UPDATE and DELETE SQL statements.
b) java.sql.PreparedStatement : An enhanced verion of java.sql.Statement which
allows precompiled queries with parameters. A PreparedStatement object is used
when an application plans to specify parameters to your SQL queries. The
statement can be executed multiple times with different parameter values
specified for each execution
c) java.sql.CallableStatement : It allows you to execute stored procedures within a
RDBMS which supports stored procedures. The Callable Statement has methods
for retrieving the return values of the stored procedure.
A ResultSet Object act like a workspace to store the results of query. A ResultSet is
returned to an application when a SQL query is executed by a statement object. The
ResultSet object provides several methods for iterating through the results of the
query.
RDBMS which supports stored procedures. The Callable Statement has methods
for retrieving the return values of the stored procedure.
A ResultSet Object act like a workspace to store the results of query. A ResultSet is
returned to an application when a SQL query is executed by a statement object. The
ResultSet object provides several methods for iterating through the results of the
query.
No comments:
Post a Comment