Horje
Retrieve Image from java database. Code Example
Retrieve Image from java database.
package com;
 
import java.io.*;
import java.sql.*;
 
public class DatabaseImageExample {

	public static void main(String args[]){
		try{
			Class.forName("com.mysql.jdbc.Driver");
			Connection con=DriverManager.getConnection("jdbc:mysql://localhost/demo","root","root");
			File file=new File("E:\\image1.png");
			FileOutputStream fos=new FileOutputStream(file);
			byte b[];
			Blob blob;
			PreparedStatement ps=con.prepareStatement("select * from image_table");
			ResultSet rs=ps.executeQuery();
			while(rs.next()){
			blob=rs.getBlob("image");
			b=blob.getBytes(1,(int)blob.length());
			fos.write(b);
			}
			ps.close();
			fos.close();
			con.close();
			}
       	 catch(Exception e){
			e.printStackTrace();
		}
	}
}




Java

Related
evaluateur d'expressions maths java Code Example evaluateur d'expressions maths java Code Example
illmatic Code Example illmatic Code Example
Association in java Code Example Association in java Code Example
convert Code Example convert Code Example
Html CSS js Code Example Html CSS js Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7