This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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: 622
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: 622
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: 622
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: 622
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: 622
Paul, please provide code examples
Kunal Lakhani
Ranch Hand

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

Joined: May 26, 2003
Posts: 30356
    
150

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: 30356
    
150

Kunal Lakhani wrote:Paul, please provide code examples

See The JDBC tutorial examples.
 
wood burning stoves
 
subject: Images in Microsoft SQL server 2005