Re: DataSource help

2004-02-13 Thread Niall Pemberton
What was the error message?

Niall

-Original Message-
From: Raman [mailto:[EMAIL PROTECTED]
Sent: 13 February 2004 12:06
To: Struts Users Mailing List
Subject: DataSource help


Hi All,

I have a problem regarding the DB connection. In my application i want to
log the session time for each session. For that I am using the Session
Listner in web.xml somthing like:
actions.SessionListenerAction

My problem is:

In my struts-config.xml file I have  defined for
my database.
what I am thinking is to call Insert query in
public void sessionCreated(HttpSessionEvent event) { }

and update query public void sessionDestroyed(HttpSessionEvent event) {}
function

But my problem is how to get and pass the DataSource that refers to my DB
defined in  tag of struts-conf file to my DAO file.

WHAT I TRIED IS:
   String name = event.getName();
   HttpSession session = event.getSession();
   ServletContext sc = session.getServletContext();
   try{
   DataSource dataSource
=(DataSource)sc.getAttribute(Action.DATA_SOURCE_KEY);
   UpdateSessionListenerDAO dao= new  UpdateSessionListenerDAO(dataSource);
   dao.insertSessionLogging(session.getId().toString());
   }catch(Exception e){
System.out.println("ERROR " + e.getMessage());
   }

But this is not working I was not able to figure out the reason.

Pls help..

-- Raman

***
This e-mail and its attachments are confidential
and are intended for the above named recipient
only. If this has come to you in error, please
notify the sender immediately and delete this
e-mail from your system.
You must take no action based on this, nor must
you copy or disclose it or any part of its contents
to any person or organisation.
Statements and opinions contained in this email may
not necessarily represent those of Littlewoods.
Please note that e-mail communications may be monitored.
The registered office of Littlewoods Limited and its
subsidiaries is 100 Old Hall Street, Liverpool, L70 1AB.
Registered number of Littlewoods Limited is 262152.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: DataSource help

2004-02-13 Thread McCormack, Chris
put a trigger on the data table you are selecting from, that inserts a timestamp in to 
a timestamplog table, when a select is done on your data table. Or create a view and 
put a trigger on that, to preserve the functionality of the data table (ie not have a 
trigger fire when you are just doing dev etc.)

-Original Message-
From: Raman [mailto:[EMAIL PROTECTED]
Sent: 13 February 2004 12:06
To: Struts Users Mailing List
Subject: DataSource help


Hi All,

I have a problem regarding the DB connection. In my application i want to log the 
session time for each session. For that I am using the Session Listner in web.xml 
somthing like: 
actions.SessionListenerAction

My problem is:

In my struts-config.xml file I have  defined for my 
database. 
what I am thinking is to call Insert query in 
public void sessionCreated(HttpSessionEvent event) { } 

and update query public void sessionDestroyed(HttpSessionEvent event) {} function

But my problem is how to get and pass the DataSource that refers to my DB defined in 
 tag of struts-conf file to my DAO file.

WHAT I TRIED IS:
   String name = event.getName();
   HttpSession session = event.getSession();
   ServletContext sc = session.getServletContext();   
   try{   
   DataSource dataSource =(DataSource)sc.getAttribute(Action.DATA_SOURCE_KEY);   
   UpdateSessionListenerDAO dao= new  UpdateSessionListenerDAO(dataSource);
   dao.insertSessionLogging(session.getId().toString());
   }catch(Exception e){
System.out.println("ERROR " + e.getMessage());
   }

But this is not working I was not able to figure out the reason.

Pls help.. 

-- Raman

***
This e-mail and its attachments are confidential
and are intended for the above named recipient
only. If this has come to you in error, please 
notify the sender immediately and delete this 
e-mail from your system.
You must take no action based on this, nor must 
you copy or disclose it or any part of its contents 
to any person or organisation.
Statements and opinions contained in this email may 
not necessarily represent those of Littlewoods.
Please note that e-mail communications may be monitored.
The registered office of Littlewoods Limited and its
subsidiaries is 100 Old Hall Street, Liverpool, L70 1AB.
Registered number of Littlewoods Limited is 262152.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



DataSource help

2004-02-13 Thread Raman
Hi All,

I have a problem regarding the DB connection. In my application i want to log the 
session time for each session. For that I am using the Session Listner in web.xml 
somthing like: 
actions.SessionListenerAction

My problem is:

In my struts-config.xml file I have  defined for my 
database. 
what I am thinking is to call Insert query in 
public void sessionCreated(HttpSessionEvent event) { } 

and update query public void sessionDestroyed(HttpSessionEvent event) {} function

But my problem is how to get and pass the DataSource that refers to my DB defined in 
 tag of struts-conf file to my DAO file.

WHAT I TRIED IS:
   String name = event.getName();
   HttpSession session = event.getSession();
   ServletContext sc = session.getServletContext();   
   try{   
   DataSource dataSource =(DataSource)sc.getAttribute(Action.DATA_SOURCE_KEY);   
   UpdateSessionListenerDAO dao= new  UpdateSessionListenerDAO(dataSource);
   dao.insertSessionLogging(session.getId().toString());
   }catch(Exception e){
System.out.println("ERROR " + e.getMessage());
   }

But this is not working I was not able to figure out the reason.

Pls help.. 

-- Raman