RE:Pregunta Basica sobre conexion a base
Revisa este código:
EJB Sesión ejbMySessionBean.java
--------------------------------------------------
public Object fncReadSQL(HttpSession sesion) throws Exception
{
try {
Vector vecRetorno = new Vector();
Object ref = clsInstanciarEjb.generarHome
("java:comp/env/mySessionEJB/mysession");
ejbMySessionHome = (ejbMySessionHome)
PortableRemoteObject.narrow(ref, ejbMySessionHome.class);
ejbMySessionRemote = (p43bBusqueda)
ejbMySessionHome.create();
String select = "SELECT * FROM MYTABLE";
vecRetorno = ejbMySessionRemote.consultaGeneral(select);
} catch (Exception ex) {
System.out.println("Error: " + ex.getMessage());
} finally {
return vecRetorno;
}
}
clsInstanciarEjb.java
------------------------------
public class clsInstanciarEjb {
public static Object generarHome (String strNombreJNDI)
{
Context ctx = null;
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL, "t3://webldes01:7142");
try {
ctx = new InitialContext(ht);
return ctx.lookup(strNombreJNDI);
} catch(Exception e) {
System.out.println("Error: " + e.getMessage());
return null;
}
}
}
Un saludo.
Ani