Spring JNDI Datasource and Development Datasource


<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
		<property name="jndiName" value="com/dev/sss" />
		<property name="defaultObject" ref="developmentDataSource" />
	</bean>

	<!-- fall back datasource if JNDI look up of main datasource fails -->
	<bean id="developmentDataSource" class="org.apache.commons.dbcp.BasicDataSource"
		destroy-method="close">

		<property name="driverClassName" value="${jdbc.driverClassName}" />
		<property name="url" value="${jdbc.url}" />
		<property name="username" value="${jdbc.username}" />
		<property name="password" value="${jdbc.password}" />

		<property name="initialSize">
			<value>10</value>
		</property>
		<property name="maxActive">
			<value>0</value>
		</property>
		<property name="maxWait">
			<value>5000</value>
		</property>

	</bean>

configuring application application.xml


Application.xml is the global configuration for JavaEE.

if you use JavaEE version you can use:

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="5"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd">

<module>
  <java>test-client.jar</java>
</module>

<module>
  <ejb>test-ejb.jar</ejb>
</module>

<module>
  <web>
    <web-uri>test.war</web-uri>
    <context-root>test</context-root>
  </web>
</module>

<library-directory>lib</library-directory>
</application>

If you use Java2EE you can use

<?xml version="1.0" encoding="UTF-8"?>
<application id="Application_ID" version="1.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
	<display-name>
	WarTestEAR</display-name>
	<module id="WebModule_1218106372121">
		<web>
			<web-uri>WarTest.war</web-uri>
			<context-root>WarTest</context-root>
		</web>
	</module>
</application>
<?xml version=”1.0″ encoding=”UTF-8″?>
<application id=”Application_ID” version=”1.4″ xmlns=”http://java.sun.com/xml/ns/j2ee&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd”&gt;
<display-name>
WarTestEAR</display-name>
<module id=”WebModule_1218106372121″>
<web>
<web-uri>WarTest.war</web-uri>
<context-root>WarTest</context-root>
</web>
</module>
</application>