java - Accessing JNDI datasource defined in Web/App Server from Spring applicationContext xml / Junit Test cases -


There are some available blogs available to define JDI datasets and then enter from Spring containers.

Method 1: Creating a file context.xml in file and defining all relevant JDD datasets in 1 Src \ main \ webapp \ META-INF folder. 2. Spring app from context.xml file & lt; Bean id = "datasource" class = "org.springframework.jndi.JndiObjectFactoryBean" & gt; Accessing JDD DataSource Using & Lt; Property Name = "jndiName" value = "java: comp / env / jdbc / mydb" /> & Lt; / Bean & gt;

Method 2: And where

pre> 1. Datatormems are defined in the server.exml file (Tomcat) and the web. Xml file has been sent in. 2. Access JDD datasets from Spring App context.xml file using JndiObjectFactoryBean with an additional resource ref attribute.

Again, what about using the bottom line to get step 2 in the above two ways? & lt; G: jndi-lookup id = "data source" jndi-name = "java: comp / env / jdbc / mydb" />

Actually I want to know which is a better server connection pooling system. Is there any benefit to an attitude on the other? Which is advanced and why?

== Edit ==

Once the application of spring refers to the reference, through reference reference, data.xml, how does the test through JNDD Will Junit use standalone JNDI resources in the web container?

Can anyone help me figure this out

Looking at the documentation, it seems that the same thing comes true in both ways.

As far as connection pooling is concerned, there is no connection with doing this with JNDI lookups. Whatever connection pool you declare in context.xml (or whatever you use) will be seen and used by spring. If you declare your connection pool as a pool, then it will be used, similarly if you or others use it.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -