Meaningless Drivel is fun!*
The moose likes JSP and the fly likes How to Upload a file to oracle database using JSP or Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to Upload a file to oracle database using JSP or Servlets" Watch "How to Upload a file to oracle database using JSP or Servlets" New topic
Author

How to Upload a file to oracle database using JSP or Servlets

lisy jessica
Ranch Hand

Joined: Oct 27, 2010
Posts: 47
Hi

I want to uplaod a file(csv or excel) to Oracle 10g database, using Jsp or Servlets....


Addfile.jsp


UploadFile.jsp


This is my code...Its not uploading the file, it is giving me Error--> Index 1, size 1. Please help me ..how to do this. I am trying to upload a csv file to oracle db from jsp page, csv file has two fields PartNo and SerialNo. The Oracle table InventoryDB_main has 23 columns including PartNo, SerialNo. Please can anyone help me how to upload a file to oracle database.

Thanks in advance
Lissy.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

Step 1: get the code out of a JSP and into a servlet. Then we can discuss step 2.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

You don't know what line of code threw that exception, do you? In your catch block you should print the whole stack trace, like this:


Only since the code is in a JSP, the line numbers in the stack trace which you get won't match the line numbers in the JSP, because the JSP is compiled into something else where the line numbers are different. So as Bear said... put the code into a servlet.
lisy jessica
Ranch Hand

Joined: Oct 27, 2010
Posts: 47
Thanks for the reply. Will try this.
Sanjeev P Kulkarni
Greenhorn

Joined: Nov 08, 2009
Posts: 20

lisy jessica wrote:Thanks for the reply. Will try this.



http://www.roseindia.net/jsp/file_upload/uploadingMultipleFiles.shtml

Try this link if you want full explanation along with the code.


Sanjeev
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

Do not use the code of that link. It irresponsibly puts code in a JSP just like we have been advising not to. The roseindia site should be avoided as its examples rarely exhibit proper practices and good coding.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Upload a file to oracle database using JSP or Servlets