JDBC driver

Driver: A driver is a software component that provides the facility to a computer to communicate with hardware. JDBC driver: A driver is a software component that provides the facility to interact java application with the database. Types of JDBC drivers: JDBC-ODBC bridge driver. Native-API driver. Network-Protocol driver. Thin driver. 1. JDBC-ODBC bridge driver: JDBC-ODBC … Read more

JDBC batch processing

The JDBC batch processing provides the facility to execute a group of related queries. A group of related queries is known as a batch. It reduces the amount of communication overhead and hence improves the performance. JDBC batch processing methods: 1. addBatch(String query): It is used to add the statement to the batch. Syntax: public … Read more

JDBC DatabaseMetaData interface

The metadata refers to the data about data. The DatabaseMetaData interface provides the facility to get the information like driver name, total number of tables and driver version etc. We can get the object of DatabaseMetaData by calling getMetaData() method of Connection interface. Syntax: DatabaseMetaData dbmd=conn.getMetaData(); Commonly used methods of DatabaseMetaData: 1. getDriverName(): It is used … Read more

JDBC ResultSetMetaData interface

The metadata refers to the data about data. The ResultSetMetaData interface provides the facility to get the information like table name, total number of column, column name and column type etc. We can get the object of ResultSetMetaData by calling getMetaData() method of ResultSet interface. Syntax: ResultSetMetaData rsmd = resultSet.getMetaData(); Commonly used methods of ResultSetMetaData: 1. … Read more

JDBC transaction management

Transaction: A transaction is a sequence of operation which works as an atomic unit. A transaction only completes if all the operations completed successfully. A transaction has the Atomicity, Consistency, Isolation and Durability properties (ACID). JDBC transaction management: By default JDBC connection is in auto-commit mode and we can’t control it i.e. whenever a SQL … Read more

Retrieve image from database in java

PreparedStatement provides the facility to store and retrieve the images in the database using JDBC. PreparedStatement methods to retrieve image: public Blob getBlob(int columnIndex) throws SQLException  Example: JDBCTest.java import java.io.FileOutputStream; import java.sql.Blob; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import com.w3spoint.util.JDBCUtil;   /** * This class is used to retrieve a image from DB. * @author w3spoint */ public … Read more

Store image in database in java

PreparedStatement provides the facility to store and retrieve the images in the database using JDBC. PreparedStatement methods to store image: 1. public void setBinaryStream(int paramIndex,InputStream stream)  throws SQLException  2. public void setBinaryStream(int paramIndex,InputStream stream,long length)  throws SQLException  Example: JDBCTest.java import java.io.FileInputStream; import java.sql.Connection; import java.sql.PreparedStatement; import com.w3spoint.util.JDBCUtil;   /** * This class is used to store a image in DB. * @author w3spoint */ public class … Read more

Retrieve file from database in java

PreparedStatement provides the facility to store and retrieve the file in the database using JDBC. PreparedStatement methods to retrieve file: 1. public Clob getClob(int columnIndex) throws SQLException Example: JDBCTest.java import java.io.FileWriter; import java.io.Reader; import java.sql.Clob; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet;   import com.w3spoint.util.JDBCUtil;   /** * This class is used to retrieve a file … Read more

Store file in database using JDBC

PreparedStatement provides the facility to store and retrieve the file in the database using JDBC. PreparedStatement methods to store file: 1. public void setBinaryStream(int paramIndex,InputStream stream)   throws SQLException  2. public void setBinaryStream(int paramIndex,InputStream stream,long length)  throws SQLException   Example: JDBCTest.java import java.io.File; import java.io.FileReader; import java.sql.Connection; import java.sql.PreparedStatement; import com.w3spoint.util.JDBCUtil;   /** * This class is used to store a file in DB. * @author w3spoint */ … Read more

JDBC CallableStatement Stored procedure batch update

The JDBC CallableStatement is used to execute the store procedure and functions. Let us study JDBC CallableStatement by batch update example. Example: insertEMPLOYEE Procedure JDBC CallableStatement Stored procedure IN parameter example. CREATE OR REPLACE PROCEDURE insertEMPLOYEE( e_id IN EMPLOYEE.EMPLOYEE_ID%TYPE, e_name IN EMPLOYEE.NAME%TYPE, e_salary IN EMPLOYEE.SALARY%TYPE) IS BEGIN   INSERT INTO EMPLOYEE ("EMPLOYEE_ID", "NAME", "SALARY") VALUES … Read more