473,505 Members | 16,332 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to store image in database using JSP

selvasoft
34 New Member
Any One Please help me i want to store my image to oracle am using JSP.
Here is my code. But this code was return NULL Pointer Error..
Whta is the problem..Am Using Html form to browse and submit image purpose.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <%@ page import="java.io.*,javax.servlet.http.HttpServletRequest,javax.servlet.ServletInputStream" %>  
  4. <%@ page import="java.io.FileWriter,java.io.IOException" %>  
  5. <%@ page import ="java.sql.*,java.io.*,java.util.*" %>
  6. <%
  7. String name=request.getParameter("fname");
  8. %>
  9. <%
  10.     String DomainName ="jdbc:oracle:thin:@192.168.251.28:1521:ms";
  11.         String UserName="mmm";
  12.         String PassWord="xxx";
  13.  
  14. try
  15. {
  16.  
  17.           Class.forName("oracle.jdbc.OracleDriver");
  18.                   Connection cn=DriverManager.getConnection(DomainName,UserName,PassWord);
  19.           PreparedStatement pst = cn.prepareStatement("insert into image(simage) values(?)");
  20.           FileInputStream fis=new FileInputStream(name );
  21.                   System.out.println("File Name" +fis); 
  22.  
  23.           byte[] b= new byte[fis.available()];
  24.  
  25.           fis.read(b);
  26.           pst.setBytes(1,b);
  27.           pst.executeUpdate();
  28.           pst.close();
  29.           cn.close();
  30. }
  31.  
  32. catch(Exception e)
  33. {
  34.  
  35. System.out.println(e);
  36. }
  37.  
  38. %>
  39. </body>
  40.  
  41. </html>
Mar 22 '10 #1
0 2367

Sign in to post your reply or Sign up for a free account.

Similar topics

3
13353
by: Karen Grube | last post by:
Hi! Each week, we receive a two-page PDF file from UPS along with a separate flat file (a CSV) The PDF file contains the overview of our weekly invoice and the CSV contains the details of each...
2
3181
by: Tim Zych | last post by:
How would I go about storing data files on my web host? I have an Access database driven website and I would like to save files and be able to download them. Can somebody point me in the right...
6
1895
by: Rudy | last post by:
Hello all! I am amazed how many posts I have read to store an image in SQL, and just as many against it. So I learned how to store an image in a SQL db and retrieve the image. A little tricky,...
21
2908
by: matvdl | last post by:
I have a system that was originally developed in asp - the pages are saved in SQL (there are over 10,000 pages) and saved to a temp directory in the server when requested by a client. I have...
10
5202
by: Peter Stojkovic | last post by:
I want store an integer-array of 1000 Values in a blob in a SQL-database. I will do this every 10 Seconds. How can I do this ???? What datatypes a have to use ??? Thanks
4
2981
by: serge | last post by:
I was working on figuring out where a certain application was storing the multiple selection choices I was doing through the app. I finally figured out that they were being store in an IMAGE data...
1
6643
by: nwebhosting | last post by:
Hello and thank you. Could you please help me with this.: i try to store images using the following code, and it just bring a blank screen. i being trying different things and i am not sure if...
0
2731
by: Skiran | last post by:
Hi to everybody, I am handling a large-scale project of MIS (Marketing information System). I am using Vb 6 as front end, Ms Access as back end and Crystal report 8 as reporting tool. 1)...
6
5082
by: Keith Hughitt | last post by:
Hi all, I've run into a strange error while trying to store some PNG images in a MySQL database using MySQLdb. When I try to insert smaller images (< 64kb or so) everything seems to work fine....
2
2444
by: gm000 | last post by:
hi i m using radiobuttonlist with images like this <asp:RadioButtonList ID="rbtnthumb1" runat="server"> <asp:ListItem Value ="News_icon.jpg"> <img...
0
7218
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7103
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7307
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7370
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7021
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5035
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4701
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1532
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.