Hi,
you can use JNDI to get a DataSource (if you use tomcat see tomcat
documentation in order to set the datasource).
Here an example code to use inside the singleton object:
//Get DB from JNDI
try {
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource dataSource = (DataSource)
envCtx.lookup("jdbc/DatabaseSource");
} catch ( NamingException e ) {
//Handle Source Code Exception
}
BR
/Amleto
-----Messaggio originale-----
Da: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Inviato: marted� 21 settembre 2004 11.11
A: [EMAIL PROTECTED]
Oggetto: Assigning a DataSource to a Business Delegate on startup
Hello there,
is there a way I can assign a DataSource to a singleton object (i.e. a
Business Delegate) on startup? I know there is the "getDataSource"
protected method in Action, but I have to pass the DataSource itself on
each call of the delegate, or I have to check whether it has been
already passed or not. Maybe it could be done with a plugin. In this
case, is there already a package that I could use? And if not, how can I
access to a DataSource outside the Action class? Thanks in advance Ciao
Antonio Petrelli
---------------------------------------------------------------------
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]