Start New Discussion within our Software Development Community

hai, friends
i have problem in inserting image into mysql database using a small java program....
here is my code for inserting image into database............

import java.io.*;
import java.sql.*;
class ImageUpload
{

public static void connection()
{
  Connection con=null;
Statement st=null;   
PreparedStatement pst=null;
 try
{ 
 	Class.forName("com.mysql.jdbc.Driver");
	System.out.println("driver is loaded");
      con=DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root","root");
       System.out.println("connection created");
	pst=con.prepareStatement();
	File obj=new File("lib.jpg");/*lib.jpg is my image file name*/
	int length=(int) obj.length();
	System.out.println(length);
	InputStream fis=(InputStream) new FileInputStream(obj);
	System.out.println(obj);
	pst.setString(1,"001");
	pst.setString(2,"sachin");
	pst.setBinaryStream(3,fis,length);
	int i=pst.executeUpdate();
         if(i<0)
	{
		System.out.println("does not inserted");
	}
	else
	{
		System.out.println("successfully inserted");
	}
}
catch(Exception e)
{
	System.out.println(" "+e);
}
}
public static void  main(String args[])
{
	connection();
}
}

actually,the image is insert into the database by using above java program...
but when i see into database after inserting it gives infinite line and at the end a beep sound after that it goes into the not reponding state as shown in the attached image file....... :confused::confused::confused:

please any one can solve this problem plzzzzzzzzzzzzz........

thanks in advance......

This article has been dead for over six months. Start a new discussion instead.