Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to upload a file in java(servlets)  RSS feed

 
Swaroop Reddy
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a module where I need to upload a file and store it to DB,I am using Oreilly's servlet package with multipart request.Now the problem is it is not allowing me to upload more than 10kb file.
one more thing the table in oracle in which I am storing the file is declared as BLOB type,now i have a problem once after the file has been stored i cant able to use select query in the sql console to view the inserted data,it is giving an exception

Please help me out
 
Jetendra Ivaturi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am replying to the second part of your query, "one more thing the table in oracle in which I am storing the file is declared as BLOB type,now i have a problem once after the file has been stored i cant able to use select query in the sql console to view the inserted data,it is giving an exception " written by you.

If the datatype is blob, you can't view that in sql prompt. You have to get it through a java programe using binarystream and redirect it to some where. That's the only way.

Thanks.
 
Ankit Garg
Sheriff
Posts: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Why don't you use the apache commons file upload library??

2. Try using Text as the datatype of the field instead of BLOB...
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankit Garg wrote:1. Why don't you use the apache commons file upload library??
I gracefully agree.

2. Try using Text as the datatype of the field instead of BLOB...
I gracefully disagree.
 
Ankit Garg
Sheriff
Posts: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bauke Scholtz wrote:
Ankit Garg wrote:2. Try using Text as the datatype of the field instead of BLOB...
I gracefully disagree.


Why so?? Is that because the contents of the file can be binary data or is there some other reason
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
TEXT is character encoded. Pure binary data ought not to be character encoded. Use BLOB or any comparable binary field offered by the RDBMS in question. Consult its docs for supported field types. You should not haul binary data through a charset. Firstly it makes completely no sense and secondly that's simply asking for trouble.
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Javacity Reddy " please check your private messages for an important administrative matter. You can check them by clicking the My Private Messages link above.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!