Lesson - 15 : JDBC - How to insert and select image from Database

Опубликовано: 30 Сентябрь 2024
на канале: Sada Learning Hub
2,025
9

Inserting a picture is nothing but storing binary data(bytes) of the picture into a database table.In JDBC we need preparestatement interface for transferring binary data from java program to database.If we want to insert a picture into a table then that table column should be of blob(binary large object) type.The following are the steps required for inserting a picture

1. Creating a java.io.File object for the picture.
2. Create java.io.FileInputStream object for reading the binary data from the file.
3. Find size of the picture file.
4. Call setBinaryStream() for inserting binarydata of the picture into an SQL statement.