aspose file tools*
The moose likes JDBC and the fly likes Images in Microsoft SQL server 2005 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Images in Microsoft SQL server 2005" Watch "Images in Microsoft SQL server 2005" New topic
Author

Images in Microsoft SQL server 2005

Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 618
I have got a project on FIR management, and i have to store & retrieve images with their respective Ids. How can we store images & retrieve them in Microsoft SQL server 2005??


kunal
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Use a suitable LOB data type. The (SQL Server specific) image data type would be a good choice.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 618
thanks Paul. Can you provide some details?? or any notes??
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

An explanation of the data type can be found in the SQL Server documentation. What else do you need to know?
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 618
I need to know process of inserting and retrieving images from SQL.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

There's no real magic here. You just write an insert statement and pass the binary stream of your image. If you were to do it dirtectly in SQL Server you would use Transact SQL to do this (see the docs I mentioned earlier), but I'm guessing you want to ultimately do this with JDBC?
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 618
yes. i want to do it with jdbc. will it cause any problem?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Nope. It's actually easier just with JDBC. Stream your image (however you are doing that) then bind it as binary stream. See PreparedStatement JavaDocs for more.
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 618
Paul, please provide code examples
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 618
No reply!!!
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29248
    
139

Kunal Lakhani wrote:No reply!!!

PatienceIsAVirtue - remember that you could need to wait up to 24 hours before someone sees your message due to work/sleep/life patterns. Bumping posts before that is highly discouraged.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29248
    
139

Kunal Lakhani wrote:Paul, please provide code examples

See The JDBC tutorial examples.
 
Don't get me started about those stupid light bulbs.
 
subject: Images in Microsoft SQL server 2005
 
Similar Threads
a q about SQL Server 2005 DB and Java
count number of coulmns in table?
how to store an image into the DataBase using oracle database
java.net.BindException: Address already in use: JVM_Bind:8080
storing images in database