Non nobis Domine...

Search


Calendar

« mayo 2008
lunmarmiéjueviesábdom
   
1
3
4
5
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
       
Hoy


Nube de tags

10.1.3.1 2008 calendario consejos curiosidades datasource documentacion eclipse ejemplo emergente expressions generics ide java javahispano libro libros oas oracle recomendacion recursividad regulas roller spring swing tips weblogicserver

Data Source en OAS 10.1.3.1

mayo 06, 2008 by Isaac Ruiz Guerra

Me encuentro haciendo algunas cosas en el OAS 10.1.3.1. - ahora entiendo la razón de la compra de BEA  XD  -

Y he requerido acceder a un dataSource, aquí les dejo el código por si le sirve a a alguien.


 

         try {
            InitialContext initContext = null;
            Hashtable ht = new Hashtable();            
            ht.put(Context.INITIAL_CONTEXT_FACTORY, "oracle.j2ee.rmi.RMIInitialContextFactory");
            ht.put(Context.PROVIDER_URL, "http:ormi://localhost:8888");
            ht.put(Context.SECURITY_PRINCIPAL, "oc4jadmin");
            ht.put(Context.SECURITY_CREDENTIALS, "mypassword");
            initContext = new InitialContext(ht);
            System.out.println("Name in space"+ initContext.getNameInNamespace());
            javax.sql.DataSource dataSource = (javax.sql.DataSource) initContext.lookup("jndi/MySQLDS");
            System.out.println("Data Source cargado sin problemas");
        } catch (NamingException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }

 

 

Asegúrense de tener en el classpath el jar: oc4jclient.jar ubicado en: <OAS>oc4j/j2ee/home/ 

Saludos... 

RuGI

Isaac Ruiz Guerra.