0% found this document useful (0 votes)
6 views1 page

Store Images in Database with JDBC

This document presents a JDBC program that demonstrates how to store an image in a MySQL database. It establishes a connection to the database, prepares an SQL statement to insert data, and uses a FileInputStream to read an image file for storage. The program executes the update and prints the number of records affected before closing the connection.

Uploaded by

detata2288
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Store Images in Database with JDBC

This document presents a JDBC program that demonstrates how to store an image in a MySQL database. It establishes a connection to the database, prepares an SQL statement to insert data, and uses a FileInputStream to read an image file for storage. The program executes the update and prints the number of records affected before closing the connection.

Uploaded by

detata2288
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JDBC program to store image into database

import [Link].*;
import [Link].*;
public class ThirdJDBC
{
public static void main(String[] args)
{
try
{
[Link]("[Link]");
Connection con=[Link]("jdbc:mysql://localhost:3306/sis","root","12345678");
PreparedStatement ps=[Link]("insert into TeamImage values(?,?)");
[Link](1,"Manish");

FileInputStream fin=new FileInputStream("[Link]");


[Link](2,fin,[Link]());
int i=[Link]();
[Link](i+" records affected");
[Link]();
}
catch (Exception e)
{
[Link]();
}
}
}

You might also like