• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

regarding inserting any file

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Any Body know how to insert any file into blob field.
Thanks,
Chandra
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chandra,
You can use stmt.setBinaryStream() to pass the file contents into a statement.
 
chandra reddy pandillapalle
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi can you share the sample code

Thanks,
Chandra
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

hi can you share the sample code



as Jeanne already point you the tip regarding your query. now its time to do some googling on your criteria.

Google is not so far from your mouse click.
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can also use setBinaryStream() but there will be some limitations for that. I guess we cannot upload more than 4KB if we use setBinaryStream(). Any ways try out the following code...

org.apache.struts.upload.FormFile formfile=Fileinfo.getFile();
//The above step gets the formfile object from Fileinfo class.
PreparedStatement ps=null;
Connection con=Coredb.getConn();
try
{
String fileName=formfile.getFileName();
int fileSize=formfile.getFileSize();
byte bb[]=formfile.getFileData();

ps=con.prepareStatement("insert into fles values(?,?,?)");
ps.setString(1,fileName);
ps.setInt(2,fileSize);
ps.setBytes(3,bb);
}
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Muhammad Saifuddin:
as Jeanne already point you the tip regarding your query. now its time to do some googling on your criteria.



Muhammed, I understand that individuals should do their homework also they have to show some efforts, but at the same time being a new user (greenhorn) the OP might have been in a curiosity to ask further. They may not be really aware of the rules. We have to understand and respect that as well.

It would be better if we can point out to the links so that they can proceed further.

I believe you agree with me.
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with Raghavan. A link to the tutorial with some sample code is a long stretch from doing someone's homework.

I was in a rush when I posted my initial reply and didn't take the time to provide a proper link. So here it is.
reply
    Bookmark Topic Watch Topic
  • New Topic