• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem Uploading Image to DB

 
Gaurav Wadhwani
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using MS Access as DB

Image attribute in Itable is OLE object

The following Servlet shows FileNotFound Exception. Even though the file is present.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've edited your code to remove irrelevant details.

Please note: there is only one instance of a servlet created for each servlet mapping: your connection is being shared by *every* request that comes in; unless you can *guarantee* that only one person will *ever* use the application, you're heading towards a world of debugging pain. Servlets *must* be thread-safe. Also note that not closing the connection will cause serious issues as well.

Where does the error actually occur? If it says the file isn't there, it likely isn't there, or you don't have access to read it.
 
Gaurav Wadhwani
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thank you for the reply.
Ok so there are two issues now. Since im making these small codes and will later compile them all to make a big Web application.

1. How do i make it thread safe? So that every user that comes in gets his own DB connection. As there will be multiple users accessing the same servlet at the same time.

2. The file exists and i have the permissions to access it.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gaurav Wadhwani wrote:1. How do i make it thread safe? So that every user that comes in gets his own DB connection. As there will be multiple users accessing the same servlet at the same time.

Don't use instance variables for the connection. I don't know if the prepared statement can be an instance variable or not.

Normally an application of any size would use some sort of connection pooling, but it really depends on how much traffic you're expecting whether or not it's worth bothering.
2. The file exists and i have the permissions to access it.

I'm a little skeptical, since Java believes otherwise. And it doesn't matter if *you* have permissions--it only matters if the app server has permissions.
 
Gaurav Wadhwani
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didnt understand this. And im expecting only 5 users max for my web application.

Don't use instance variables for the connection. I don't know if the prepared statement can be an instance variable or not.

Normally an application of any size would use some sort of connection pooling, but it really depends on how much traffic you're expecting whether or not it's worth bothering.



I dont know how to set permission for a File IO in glassfish. However, since i saw most of the websites for this tutorial, none had mentioned about permissions, so i guessed it already has.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic