Results 1 to 2 of 2

Thread: image insertion

  1. #1
    KiranA is offline Member
    Join Date
    Jul 2011
    Posts
    23
    Rep Power
    0

    Default image insertion

    import java.sql.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;

    public class InsertImage extends HttpServlet{
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws

    ServletException, IOException{
    PrintWriter pw = response.getWriter();


    String connectionURL = "jdbc:mysql://localhost:3306/employee";

    Connection con=null;

    try{
    Class.forName("com.mysql.jdbc.Driver").newInstance ();
    pw.println("image11");
    con = DriverManager.getConnection(connectionURL, "root", "");

    PreparedStatement ps = con.prepareStatement("INSERT INTO picture VALUES(?,?)");
    File file = new File("E:/image.jpeg");
    FileInputStream fs = new FileInputStream(file);
    ps.setInt(1,1);
    ps.setBinaryStream(2,fs,fs.available());
    int i = ps.executeUpdate();
    if(i!=0){
    pw.println("image inserted successfully");

    }else{
    pw.println("image not inserted successfully");
    }
    } catch (Exception e){
    System.out.println(e);
    }
    }
    }..



    none of the message is displayed in the server
    (pw.println("image inserted successfully")/pw.println("image not inserted successfully");;... can anybody tell what is wrong in it? why is not getting displayed?

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,044
    Blog Entries
    7
    Rep Power
    23

    Default

    Double posted here. I'm closing this thread.

    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

Similar Threads

  1. Insertion Problem
    By balaji csc in forum Web Frameworks
    Replies: 0
    Last Post: 12-08-2009, 04:26 PM
  2. image insertion into database
    By abhiN in forum JDBC
    Replies: 4
    Last Post: 01-05-2009, 06:09 AM
  3. Regarding Data Insertion
    By adeeb in forum JDBC
    Replies: 1
    Last Post: 06-22-2008, 05:26 AM
  4. Using PreparedStatement for insertion
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-06-2008, 10:30 AM
  5. database insertion
    By abhiN in forum New To Java
    Replies: 0
    Last Post: 01-17-2008, 08:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •