• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting user name from session inside getconnection method

 
kundan varma
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI All
I want to get username from session inside getConnection method without sending that as parameter.
My connection method is defined like this
public static Connection getConnection(String from)
{
Connection conn = null;
if(dataSource == null)
{
try
{
InitialContext ic= new InitialContext();
dataSource= (DataSource) ic.lookup("jdbc/OracleDS");
}
catch (NamingException e)
{
e.printStackTrace();
return null;
}
}

try
{
conn= dataSource.getConnection();
conn.setAutoCommit(false);
return conn;
}
catch(SQLException e)
{
e.printStackTrace();
return null;
}
}

I want to get a username inside this from session.THis method is getting called from stateless session beans.
I dont want to change the parameter because i have to reflect that at all places.Iwant to store username somewhere from where i acn fetch it inside this method .Is there any solution for this.
THanks
kundan
 
kundan varma
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranch community
Any help.
I am waiting for some inputs on this subject.
THanks
kundan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic