Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-07-2008, 09:39 AM
Moderator
 
Join Date: Nov 2007
Posts: 1,637
Java Tip will become famous soon enoughJava Tip will become famous soon enough
Inserting file in to database
You may add files to the database if it supports BLOB types. The code snippet below adds a file with its name into a table called testImage.

Code:
File f = new File(fName); FileInputStream in = new FileInputStream(f); byte[] image = new byte[(int) f.length()]; in.read(image); String sql = "INSERT INTO testImage VALUES(?,?)"; PreparedStatement stmt = c.prepareStatement(sql); stmt.setString(1, name); stmt.setBytes(2, image); stmt.executeUpdate(); stmt.close();
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loding file into database venki4java Advanced Java 2 04-09-2008 12:25 PM
Inserting string with slash character into database Java Tip Java Tips 0 02-07-2008 09:57 AM
Inserting into a table (Example) Java Tip Java Tips 0 02-06-2008 10:25 AM
passing image file to database abhiN Advanced Java 2 01-21-2008 07:30 AM
save file to database katerinaaa New To Java 0 08-14-2007 01:15 PM


All times are GMT +3. The time now is 10:01 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org