Using Weblogic Datasource thru JNDI in Spring

Thanks to Spring 3.0, this turned out to be too easy. Heres what I have done to my app :

First, I created a datasource called akappdbds in Weblogic and I have set the target as the admin server so that it gets available to all webapps hosted in the server.

image

Now, inside my dispatcher-servlet.xml, namely my spring context file, I have used the <jee:jndi-lookup/> tag as :

<jee:jndi-lookup id="akappdbdatasource" jndi-name="akappdbds" expected-type="javax.sql.DataSource"/>

This creates a bean with the id and it can be used as the datasource for the project. The parameter jndi-name given in this tag must match the jndi name of the weblogic datasource. Once this was done, I have injected the akappdbdatasource bean into my dao class as :

<bean name="loginDaoImpl" class="com.akapp.dao.impl.LoginDaoImpl">
        <property name="dataSource" ref="akappdbdatasource" />
    </bean>

Once this is done, I can use the datasource in my dao to access the database and do whatever I need with the database objects.

Next is the EntityManager that I will be working on. Lets see how long it takes for me to master that one Smile

More From Author

The closest thing to replace pen and paper for good :)

I have used two other styluses namely, the Bamboo Stylus and the Cregle iPen. By…

Apple Event October 2012

Been watching the live streaming of the Oct 23rd apple event. This is the event where…

Bootcamping Windows 8

Finally installed Windows 8 to Bootcamp(to non-mac users, this means that the windows now runs…

Leave a Reply

Your email address will not be published. Required fields are marked *