14
The SQL language consists of statements that create, manipulate, and extract data from a
relational database. JDBC provides an object-oriented representation of these SQL statements. This
representation is called the java.sql.Statement interface. Statement objects send SQL commands to a
database, which can be any of the following types:
A data definition command such as CREATE TABLE or CREATE INDEX
A data manipulation command such as INSERT or UPDATE
A SELECT statement for performing a query
Data manipulation commands return a count of the number of rows modified, whereas a SELECT
statement returns a set of rows known as a result set.
The Statement interface has two specialized sub interfaces:
Prepared Statement - It uses precompiles SQL Callable Statement -It invokes stored procedures.
Statement
The basic interface for creating a statement is java.sql.Statement. It is obtained from the
connection object with Connection.createStatement().
Example:
Connection con = null;
try {
con = DriverManager.getConnection(URL);
Statement stmt = con.createStatement();
...
stmt.close();
}
finally {
if (con != null)
con.close();
}
Once a statement is created, it can be used to execute commands. The following four methods are used to
execute commands
executeUpdate
executeQuery
execute executeBatch.
21.(b)(i). Write a JSP program to find the maximum of the given numbers.[5]
<html>
<body>
<%
int a=40,b=27,c=80;
if(a>b)
{
if(a>c)
out.println(―BIG=‖+a);
else
out.println(―BIG=‖+c);
}
else
{
if(b>C)
out.println(―BIG=‖+b);
else
out.println(―BIG=‖+c);