• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can i append my session varable name to resultset object name?

 
bala manian
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi frds..
can i append my session varable name to resultset object name?ie

in normal case

ResultSet rstuser;

but in my case:

session = request.getSession(true);
String susername=(String)session.getAttribute("username");

example,assume session username value is dani.then i want resultset object name as like

ResultSet danirstRegister;

it possible?please help..urgent..thanks in advances
 
bala manian
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry wrongly type in pervious post.i want as

ResultSet danirstuser
 
John Pradeep.v
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bala,
Could you also mention the need for such an approach? It might be helpful to better understand the problem
 
bala manian
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your reply john...when many user accessing same java class..resultset value of first request user is showing to other request user...we found session handling good,but we found problem in displaying resultset value for appropriate user.so we feel resultobject based on session username may resolve these problem.what you guys feel?or may other problem?please it urgent issue..waiting for your reply guys..thanks in advances...
 
xsunil kumar
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bala, i donot think so , you can do this.
 
bala manian
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what may be other way to resolve these problem..?any suggestion..waiting..
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65122
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to stop thinking about silly solutions and find out why your data is being shared inappropriately across sessions.

It sounds like a threading issue. Are you perhaps using instance variables in a servlet?
 
bala manian
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes am using instance variable.here it my part of my coding

String strAuto="---------------";
PreparedStatement prest=con.prepareStatement(strAuto);
ResultSet Rst=prest.executeQuery();
while(Rst.next())
{
strLastNumber=Rst.getString(1);
}
 
John Pradeep.v
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bala,
You cannot have different variables for different users, this is exactly why session management is used for... I don't know the exact structure/design of your code.. but i think you are not using session properly or you are sharing the instance variable in a servlet or you might have a static variable holding the result set..

can you paste the full class file here?

Regards,
John
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34851
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) How does that code snippet relate to the session? Do you have some list of active session variables?
2) It is good practice to close the result set quickly. This means looping through it and storing the results in a data structure. That data structure could be stored in the session. Or even a Map with the name as key if you have some reason you can't use a session.
 
bala manian
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i have...i said abt my session variable in first post itself...i closed my resultset in finally block only.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34851
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bala manian wrote:yes i have...i said abt my session variable in first post itself...i closed my resultset in finally block only.

I don't understand what you are trying to accomplish with the multi-named variables. I don't see that explained in the first post.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65122
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suspect that the poster is encountering threading issues and is looking in the wrong place to solve it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic