"Shawn Chambers" <[EMAIL PROTECTED]> writes:
> Hi,
>
> public void getConnection() throws Exception
> {
> Hashtable env = new Hashtable();
> env.put(Context.INITIAL_CONTEXT_FACTORY,
> "org.jnp.interfaces.NamingContextFactory");
> env.put(Context.PROVIDER_URL, "localhost:1099");
> env.put(Context.URL_PKG_PREFIXES,
> "org.jboss.naming:org.jnp.interfaces");
>
> dbConnection =
> ((DataSource)new InitialContext(env).lookup("java:/InformixDB"))
> .getConnection();
>
> }
Don't hold a reference to the connection in the EJB. Try this:
public Connection getConnection() throws Exception
{
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "localhost:1099");
env.put(Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");
return ((DataSource)new InitialContext(env).lookup("java:/InformixDB"))
.getConnection();
}
and use it like this:
public void ejbStore() // or load etc.
Connection con = null;
try {
...
con = getConnection();
...
}
...
finally {
//close connection etc.
}
Just get the connection when you need it. If this is not an option,
try marking the connection member as transient.
--
Lars
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user