Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package sqltest;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.FileOutputStream;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import java.sql.PreparedStatement;
- /**
- *
- * @author Abdullah
- */
- public class WriteBLOB {
- public static void main(String[] args) throws SQLException, FileNotFoundException{
- String url="jdbc:mysql://localhost:3306/demo?autoReconnect&useSSL=false";
- String user="root";
- String password="abdullah";
- String SQL=
- "UPDATE employee1 SET resume=? WHERE id=2"
- ;
- File file=new File("D:\\jdbc-blob\\sample_resume.pdf");
- FileInputStream IS=new FileInputStream(file);
- Connection connect=DriverManager.getConnection(url,user,password);
- PreparedStatement PS=connect.prepareStatement(SQL);
- PS.setBinaryStream(1, IS);
- PS.executeUpdate();
- }
- }
Add Comment
Please, Sign In to add comment