Professional Documents
Culture Documents
JDBC
JDBC
JDBC
What is JDBC
JDBC Stands for Java Database Connectivity The JDBC API provides universal data access from the Java programming language. Using the JDBC API, you can access virtually any data source, from relational databases to spreadsheets and flat files.
JDBC Drivers
To use the JDBC API with a particular database management system, you need a JDBC technology-based driver to mediate between JDBC technology and the database. Depending on various factors, a driver might be written purely in the Java programming language or in a mixture of the Java programming language and Java Native Interface (JNI) native methods.
JDBC Portability
To make JDBC DBMS independent it defines a set of interfaces that developers will irrespective of which driver they are using Under the wraps the database specific driver provides the implementation for these interfaces
java.sql.Statement
The object used for executing a static SQL statement and returning the results it produces.
java.sql.ResultSet
A table of data representing a database result set, which is usually generated by executing a statement that queries the database.
When using JDBC prior to obtaining a Connection one needs to load the driver class. Once that is done the connection can be obtained and further steps can be carried out as shown.
Types of Statement
Statement PreparedStatement
These are precompiled and stored in a PreparedStatement object. This object can then be used to efficiently execute this statement multiple times.
CallableStatement
Used to execute SQL stored procedures.
TYPE_SCROLL_INSENSITIVE
A ResultSet object that is scrollable but generally not sensitive to changes made by others.
TYPE_SCROLL_SENSITIVE
A ResultSet object that is scrollable and generally sensitive to changes made by others.