• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java I/O  RSS feed

 
Ola Daniel
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this nasty bug in my code, here goes:

I am reading a Blob file from my oracle database and writng it out into my server(Jboss) filesystem in a POJO. Then I send a link to my JSP(View) via request attribute so that my user can see the file.

The problem is whenever i run my code on my web server. The file that i read from the database does not come out right(it comes out as 86KB of unreadable rubbish). What i mean is, it does not work. But when i run the same code normally. Everything works okay.

Here is my code:


the bold part of the code is where i suspect im something is wrong. Suggestions please.
 
Paul Clapham
Sheriff
Posts: 22521
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using a DataOutputStream is a waste as far as I can see, since writing the bytes directly to the BufferedOutputStream should work just as well. And it could also be modifying the bytes in some way, which would not be what you want. So first of all get rid of that.

It's also possible that the error occurs here:or that you actually have unreadable rubbish in your database. Check out those possibilities too.
 
Ola Daniel
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

--------------------------------------------------------------------------------
Using a DataOutputStream is a waste as far as I can see, since writing the bytes directly to the BufferedOutputStream should work just as well. And it could also be modifying the bytes in some way, which would not be what you want. So first of all get rid of that.

It's also possible that the error occurs here:


or that you actually have unreadable rubbish in your database. Check out those possibilities too.


Ive checked out the possibilities mentioned above.
Used this code instead


And i'm sure the files inserted into the database isnt rubbish. Because I run the same code I pasted earlier from the command prompt and successfully transfered the files out of the database to my hard disk.

Its really a odd bug. It doesnt make any sense. Runnning the same code as a web app. The files comes out as junk.


And I agree using the DataOutputStream is totally unneccessary. I only added it out of desperation..... right now my head hurts. There is no reason why this should be happpening!
 
Ola Daniel
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem solved. the problem was with my JBoss Server. I configured a new server and my code worked.


 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!