how to insert a image in oracle 10g using JSP

how can i insert a image in oracle 10g useing jsp

Page 1 of 1

2 Replies - 11064 Views - Last Post: 22 July 2009 - 11:35 AM

#1 mohammedariff  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 06-May 09

how to insert a image in oracle 10g using JSP

Post icon  Posted 06 May 2009 - 01:21 AM

Please help me how can i insert a image in oracel10g.Using jsp.....
Thanks
Regards
Mohammed Ariff
Is This A Good Question/Topic? 0
  • +

Replies To: how to insert a image in oracle 10g using JSP

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8334
  • View blog
  • Posts: 31,858
  • Joined: 06-March 08

Re: how to insert a image in oracle 10g using JSP

Posted 06 May 2009 - 05:33 PM

[rules][/rules]
Was This Post Helpful? 0
  • +
  • -

#3 srikanta422  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 22-July 09

Re: how to insert a image in oracle 10g using JSP

Posted 22 July 2009 - 11:35 AM

View Postmohammedariff, on 6 May, 2009 - 12:21 AM, said:

Please help me how can i insert a image in oracel10g.Using jsp.....
Thanks
Regards
Mohammed Ariff

First Create a Table


CREATE TABLE  "IMAGEMAIN" 
   (	"ID" NUMBER, 
	"IMAGE" BLOB
   )
/

this should be written in index.html
 <form name="frm" method="post" action="index.jsp">
		<input type="text" name="hint">
		<input type="file" name="user_file"> 

this should be written in index.jsp
try{  
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Connection loaded");
Connection con = DriverManager.getConnection("jdbc:odbc:project","image","image"); 
System.out.println("Connection created");
String ll=request.getParameter("user_file");
String lo=request.getParameter("hint");
File imgfile = new File(ll);

FileInputStream fin = new FileInputStream(imgfile);

PreparedStatement pre = con.prepareStatement("insert into IMAGEMAIN (id,image) values(?,?)");
pre.setString(1,lo);
pre.setBinaryStream(2,fin,(int)imgfile.length());
pre.executeUpdate();
pre.close();
}catch(Exception E){ out.println("the eror is  "+ E);}


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1