Java Database Connectivity
Java Database Connectivity
connect Java application with Database. JDBC is used to interact with various type of Database
such as Oracle, MS Access, My SQL and SQL Server. JDBC can also be defined as the
platform-independent interface between a relational database and Java programming. It allows
java program to execute SQL statement and retrieve result from database.
They also define methods that help bridge data type differences between
Java and SQL data types used in a database.
PreparedStatement Use the when you plan to use the SQL statements many
times. The PreparedStatement interface accepts input
parameters at runtime.
CallableStatement Use the when you want to access the database stored
procedures. The CallableStatement interface can also accept
runtime input parameters.
Once you've created a Statement object, you can then use it to execute
an SQL statement with one of its three execute methods.
A simple call to the close() method will do the job. If you close the
Connection object first, it will close the Statement object as well.
However, you should always explicitly close the Statement object to
ensure proper cleanup.
All of the Statement object's methods for interacting with the database
(a) execute(), (b) executeQuery(), and (c) executeUpdate() also work
with the PreparedStatement object. However, the methods are modified
to use SQL statements that can input the parameters.
Closing PreparedStatement Object
Just as you close a Statement object, for the same reason you should
also close the PreparedStatement object.
A simple call to the close() method will do the job. If you close the
Connection object first, it will close the PreparedStatement object as
well. However, you should always explicitly close the PreparedStatement
object to ensure proper cleanup.
SERVLET
Introduction to Web
Web consists of billions of clients and server connected through wires and wireless networks.
The web clients make requests to web server. The web server receives the request, finds the
resources and return the response to the client. When a server answers a request, it usually
sends some type of content to the client. The client uses web browser to send request to the
server. The server often sends response to the browser with a set of instructions written in
HTML(HyperText Markup Language). All browsers know how to display HTML page to the client.
Web Application
A website is a collection of static files(webpages) such as HTML pages, images, graphics etc.
A Web application is a web site with dynamic functionality on the
server. Google, Facebook, Twitter are examples of web applications.
HTTP is a protocol that clients and servers use on the web to communicate.
It is similar to other internet protocols such as SMTP(Simple Mail Transfer Protocol) and
HTTP is a stateless protocol i.e HTTP supports only one request per connection. This
means that with HTTP the clients connect to the server to send one request and then
disconnects. This mechanism allows more users to connect to a given server over a period
of time.
The client sends an HTTP request and the server answers with an HTML page to the client,
using HTTP.