Hi,
I am fresher in Java.I have inserted image in database.
I dont know how to retrieve it.
Below code will help u to insert the image.
Thank u.
Have a nice time.
import java.sql.*;
import java.io.*;
public class JDBCTRY6
{
// using blob and clob
public static void main(
String args[])
{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("DriverLoaded");
Connection con = DriverManager.getConnection("jdbc:odbc:sandsn","scp11_14","shower");
System.out.println("Connected to db");
//adding blob and clob
File f1 = new File("ash.txt");
FileInputStream text = new FileInputStream (f1);
File f2 = new File("sai.gif");
FileInputStream images = new FileInputStream (f2);
PreparedStatement ps = con.prepareCall("insert into imagetable values(?,?)");
ps.setAsciiStream(1,text,(int)f1.length());
ps.setBinaryStream(2,images,(int)f2.length());
ps.executeUpdate();
System.out.println("record inserted");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("In catch block");
}
}
}