What are the types of statements in JDBC?
The JDBC API has 3 Interfaces,
·
Statement,
·
PreparedStatement,
·
CallableStatement
The key
features of these are as follows:
Statement
This interface is used for executing a static SQL
statement and returning the results it produces.
The object of Statement class can be created using
Connection.createStatement() method.
PreparedStatement
A SQL statement is pre-compiled and stored in a
PreparedStatement object.
This object can then be used to efficiently execute
this statement multiple times.
The object of PreparedStatement class can be created
using Connection.prepareStatement() method. This extends Statement interface.
CallableStatement
This interface is used to execute SQL stored
procedures.
This extends PreparedStatement interface.
The object of CallableStatement class can be created
using Connection.prepareCall() method.
What is Connection pooling? What are the advantages of using a
connection pool?
Connection Pooling is a technique used for sharing
the server resources among requested clients. It was pioneered by database
vendors to allow multiple clients to share a cached set of connection objects
that provides access to a database.
Getting connection and disconnecting are costly
operation, which affects the application performance, so we should avoid
creating multiple connection during multiple database interactions. A pool
contains set of Database connections which are already connected, and any
client who wants to use it can take it from pool and when done with using it
can be returned back to the pool.
Apart from performance this also saves you resources
as there may be limited database connections available for your application.
Visit:www.sssedu.inhttp://sssedu.in/java-training-in-chennai.html
No comments:
Post a Comment