How to access JNDI data source defined in weblogic 10.3.6

前端 未结 3 1543
梦毁少年i
梦毁少年i 2021-01-18 00:32

I have created a JNDI data-source using my weblogic console but I am not able to access the object from my web application. Below are the details

In weblogic 10.3.6,

3条回答
  •  清歌不尽
    2021-01-18 01:25

    After referring to the post:Tomcat vs Weblogic JNDI Lookup I have modified my code.

    Using below code in my java program of web application has solved my issue:

    Context initContext = new InitialContext();
    DataSource ds = (DataSource)initContext.lookup("jdbc/mydb");
    jndiConnection = ds.getConnection();
    

    Also in weblogic console I have added my JNDI object to my Admin Server (under servers option) where my web application is deployed.

提交回复
热议问题