TSS feedback: jpg store in db

  1. jpg store in db (2 messages)

    I want to store some jpg or (picture file) gif files stored in database .if any one help me with example

    Threaded Messages (2)

  2. jpg store in db[ Go to top ]

    here u are... this example is for DB2. See if it works for u. You may customise it a bit to make it meet your requirements. the code below will store your images for u.
    Note: may cause file truncation if the jpg file is too large!
    Mansoor Jafary

    import java.sql.*;
    import java.io.*;

    public class FileTable{
    private Connection conn;
    private PreparedStatement pstmt;
    private ResultSet rs;
    private String url = "jdbc:odbc:FileDB";
    private File file = new File("Lcasta19.jpg");

    public FileTable(){
    conn = DriverManager.getConnection(url, "admin", "admin1");
    pstmt = conn.prepareStatement("INSERT INTO FileTable(ID, FILE) values(35, ?)");
    FileInputStream fin = new FileInputStream(file);
    Long val = new Long(file.length());
    int val1 = val.intValue();

    pstmt.setBinaryStream(1,fin, fin.available());
    catch(Exception e){
    public static void main(String args[]){
    new FileTable();

  3. jpg store in db[ Go to top ]

    Actually this code not working properly.can u check it and resend please help me