• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to store image in MS SQL Server

 
Lokendra Shekhawat
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi friends,
I want to store images (.jpg or .png or .gif) in MS SQL Server 2005 database using JDBC-ODBC connectivity in servlet. can anybody give me step by step procedure to do it.
I don't wan't to store the reference to images, instead i want to store actual image file in a database.

Please give me step by step procedure to do it.

Thank You
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried anything yourself? What do you think the step-by-step procedures should be?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This forum is for questions on Servlets, not JDBC. For more information, please read this.

This post has been moved to a more appropriate forum.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33700
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lokendra Shekhawat wrote:Please give me step by step procedure to do it.

You'll want to read up on BLOBs in the JDBC tutorial.
 
amrish sharma
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using the following code for storing image in ms sql server 05

i have wriiteen the following sql script





but when executed it shows this exception

java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '�'.
please help !
 
Lokendra Shekhawat
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am also getting the same error. aren't there any way around it. can't we store image on the database at all???
 
amrish sharma
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya i think the same there is no way to store images in sql server using servlet
so i gonna change the idea now i am going to give the clients selective images only already uploaded on server..

bye with some (cry and pain)
wait wait
i also downloaded "jtds-1.2.3-dist" driver for sql server but the same problem occured now i think its a problem of ODBC or the ms sql server

loks checkout here : http://www.java.happycodings.com/JDBC/code3.html
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's probably not the source of the problem, but one thing you need to fix is the following code: ReadDoesntDoWhatYouThinkItDoes

File f=new File("D://124744.jpg");
FileInputStream in=new FileInputStream(f);
byte [] b=new byte[(int)f.length()];
in.read(b);
 
malik saad
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

String pic="INSERT INTO Images VALUES(?)";

The above live Image as Table name ,but its entity or column is not mentioned like "INSERT INTO Images(ColumnName) VALUES(?)"; which is main requirement so makes exception ..

 
Rob Spoor
Sheriff
Pie
Posts: 20396
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

It's not required to add the column names; if you omit them it's equivalent to adding all column names. In this case there is only one column so there is no need to specify the column name.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic