-
1. Re: how to get a jdbc connection in the session bean
lasterra Apr 24, 2002 9:10 PM (in response to cs710)protected Connection getConnection()
{
String mensajeLog =
"Cogiendo conexion en " + this.getClass ().getName ();
if (log.isDebugEnabled ()) log.debug (mensajeLog);
try {
InitialContext context = new InitialContext ();
DataSource source = (DataSource)context.lookup ("java:/MK");
return source.getConnection ();
}catch(javax.naming.NamingException ne)
{
throw new javax.ejb.EJBException(mensajeLog,ne);
}catch (java.sql.SQLException sqle)
{
throw new javax.ejb.EJBException(mensajeLog,sqle);
}
where MK is my connection pool.
If you don't like edit the deploy jars, use xdoclet and left it generates this files for you.
Regrasds, enrique. -
2. Re: how to get a jdbc connection in the session bean
cs710 Apr 25, 2002 2:25 PM (in response to cs710)Thanks. It works.
-
3. Re: how to get a jdbc connection in the session bean
davidjencks Apr 25, 2002 9:26 PM (in response to cs710)2. Use the XDataSourceLoader (in 2.4.x). Otherwise there is no way for the transaction manager to control the transactions for you. Most dbs don't have working xa drivers, so there is the XADataSourceImpl which makes non xa look like xa (but without actually doing 2pc).
If you are using db + transacted jms, you want real xa, such as Firebird and expensive db's have.
3. I only work on 3.0 and still think the $$2.4 docs are worth it. You might find it at your bookstore, too, and take a look.
4. I recommend xdoclet also.