• 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

jsp/jdbc - Tomcat

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My requirement is once i issue a request from my jsp (the request is a sql query) it has to hit the database and should
return the number of affected row but should not commit it . In the next request from jsp the user will either hit
commit button or rollback button and based on the request it will either commit or rollback .In order to acheive this i
believe i have use the same connection object for both request.

I know http is stateless and i have to use the same connection object for both the request . Is it good to have connection object in session

1) How can i use the same connectionobject in both request.?

2) What if the user did not click commit or rollback button . How can i expire the connection object that was opened during first request
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not a good idea. Even in the best cases, that holds a database connection open way too long. But what about where the user gets up and goes to lunch before committing? Or just gets bored and goes to surf web comics?

What are you really trying to accomplish? There will be a better way to do it.
 
vinitha simon
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes i understand . But my client needs it . I tried to convince them but they were not ready to listen it . So if the user do not use the connection for a while i have to expire it . Can you give me some suggestions .
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is it exactly that the clients asked for? They rarely go into such technical details. I'm willing to bet that there's a much better to deliver what they need.
 
vinitha simon
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is some thing for Admin purpose . The requirement is

1) In my fisrt jsp i should have a textarea that accepts the sql query and i will call an external stored proc that will return the number of rows affected which will be displayed as response in the jsp .But the stored proc won't commit the data . If i get the response my jsp will display two buttons commit and rollback .Now the user will decide wheter to commit or rollback .

Inorder to do that i thought i should have same connection object . Let me know if iam wrong .
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's your responsibility as a consultant to explain to the client that this is a very bad idea indeed.
But why does displaying the number of rows affected involve changing them? Surely you can figure out how many rows would be affected without actually changing them?
Or are you worried about DB changes occurring between seeing the count, and actually committing the changes? If so, why does that matter?
 
reply
    Bookmark Topic Watch Topic
  • New Topic