• Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp/jdbc - Tomcat

 
vinitha simon
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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 .
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • 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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!