I want to get the connection using weblogic server 6.0 datasource. For my Jndi context i always use same credential and other parameters as required to create InitialContext object. Should I declare DataSource object as static variable in my class or instanace variable.
Is JNDI lookup for each http request is expensive.
If i design a singleton class that use same DataSource object for all the simultaneous clients. Is it save to do that or i should not use singleton
pattern that creates a single DataSource Instance? In other words i should create a new DataSource object for each request to get connection?
Note : I am also using the connection pooling so i always return connection after executing my query?
// Is is to save to use same datasource object when Datasource object is shared among the concurrent clients
public class ServiceLocator{
private DataSource ds;
private static ServiceLocator sl;
public static getInstance(){
if (sl == null){
sl = new ServiceLocator();
}
return sl;
}
private ServiceLocator(){
try {
Context ctx = new InitialContext(ht);
ds = (javax.sql.DataSource) ctx.lookup ("myJtsDataSource");
} catch (NamingException e) { }
}
public Connection getConnection(){
return ds.getConnection();
}
[This message has been edited by Nasim Sohail (edited September 13, 2001).]
[This message has been edited by Nasim Sohail (edited September 13, 2001).]