This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills: The software developer's life manual and have John Sonmez on-line!
See this thread for details.
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OpenCSV Error on server

 
Eduardo Ponce de Leon
Ranch Hand
Posts: 99
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have my projec where I upload a file and it insets it into a DB. When I run my project in eclipse everything works like a charm, howeve when I export my project to a .war file and deploy in my Tomcat Server and try to upload the same file. I get the following error.



I noticed that for some reason a .jar from is not getting exported, so I added it manually to my .war file but this still does not solve my problem, what am I missing or doing wrong. Or is it just simply that since my file is on my local computer then the server cannot find it? If so, how do I pass a path to the server from my local computer to use that file and insert it to a DB. This is my current method that works if I run my app in eclipse.

 
Piyush Mangal
Ranch Hand
Posts: 196
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should not be giving the local file path as a request parameter. if you requirement is to upload a file and then insert that into db then you will require 3rd party jars like commons-fileupload
to upload the file to servlet and then you can save the uploaded file to db.
 
Eduardo Ponce de Leon
Ranch Hand
Posts: 99
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok! Maybe I didnt explain myself, I am not trying to save the file to the dabase. I am trying to open the file with OpenCSV read the file, take the colums that I need and Insert them into my database. But I am unsure on how to do all this from the server.
 
Piyush Mangal
Ranch Hand
Posts: 196
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, don't save the file into database if not required. But still you will need to upload the file through 3rd party lib like commons-fileupload and you will receive a byte[] array at server side. Now you can do whatever you want to do with byte[]. You can create a File object and extract the desired columns out of it.
 
Rob Spoor
Sheriff
Pie
Posts: 20368
43
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't even need to create a file; use a ByteArrayInputStream wrapped in an InputStreamReader to provide to the CSVReader.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic