• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java I/O

 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problem solved. the problem was with my JBoss Server. I configured a new server and my code worked.


reply
    Bookmark Topic Watch Topic
  • New Topic