Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
lisy jessica
Ranch Hand
Posts: 47
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Step 1: get the code out of a JSP and into a servlet. Then we can discuss step 2.
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. Will try this.
 
Sanjeev P Kulkarni
Greenhorn
Posts: 20
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic