Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Images in Microsoft SQL server 2005

 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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??
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a suitable LOB data type. The (SQL Server specific) image data type would be a good choice.
 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Paul. Can you provide some details?? or any notes??
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to know process of inserting and retrieving images from SQL.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes. i want to do it with jdbc. will it cause any problem?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul, please provide code examples
 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No reply!!!
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34672
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34672
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kunal Lakhani wrote:Paul, please provide code examples

See The JDBC tutorial examples.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic