1. springjndi data source configuration information:
<Bean id = "datasource" class = "org. springframework. JNDI. jndiobjectfactorybean">
<Property name = "jndiname">
<Value> JAVA: COMP/ENV/jcptperformancejndi </value>
</Property>
</Bean>
The underline is the JNDI configured by tomcat or other application servers.
2. Configure JNDI (Tomcat ):
Modify the conf/context. xml file in the Tomcat directory:
<Resource Name = "jcptdatasourcejndi" auth = "Container" type = "javax. SQL. datasource"
Maxactive = "100" maxidle = "30" maxwait = "10000" username = "tysp"
Password = "12345678" driverclassname = "oracle. JDBC. Driver. oracledriver"
Url = "JDBC: oracle: thin: @ 192.168.1.105: 1521: OA"/>
3. Obtain datasource through JNDI:
Context context = new initialcontext ();
Datasource DS = (datasource) Context. Lookup ("Java: COMP/ENV/jcptdatasourcejndi ");