JDBC

JDBC Projects

JDBC Project 1

adplus-dvertising
Statement of the JDBC
Previous Home Next

There are three types of statement is available in the JDBC, which are listed bellow-

  1. Statement
  2. PreparedStatement
  3. CallableStatement
Statement

JDBC Statement is an interface of java.sql.*; package, which is used for execution of SQL statement. Statement returns an object, which is contain the result. Statement interface provides basic method for SELECT, UPDATE, INSERT, DELETE query in the database. The query which is stored in object compiled every time when request is made. the statement is little slower than preparedStatement.

PreparedStatement

The preparedStatement is access the functionality of java.sql.Statement and add some extra feature in it.This version of the statement allows to precompile the query. In the preparedStatement, the query do not compile every time when the request is made. Creating a PreparedStatement:-

PreparedStatement psmt=con.prepareStatement(" SELECT * from student");

This psmt object contains the record of the Students table, which is sent to the DBMS for execution.Now you are pass the parameter to psmt object as

psmt.setString(3,"Sam");

This sets the String "Sam" to the third column of the Student table.

JDBC CallableStatement

JDBC Callable statement is a way of calling the store procedures of the database. It procedure stored in the database.It calls are written in escape syntax which may take one or two forms.The CallableStatement object is created by calling a prepareCall() method of connection,Syntax is given below:-

CallableStatement cstmt = connection.prepareCall("CALL HI()");
Previous Home Next