需要weblogic.jar和jrmpclient.jar
weblogicjndi.properties
class="java">
jndiName=DataSource
jndiUrl=t3://192.168.1.10:7001
jndiInitial=weblogic.jndi.WLInitialContextFactory
applicationContext.xml
<bean id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>${jndiName}</value>
</property>
<property name="resourceRef">
<value>true</value>
</property>
<property name="jndiEnviroment">
<props>
<prop key="java.naming.provider.url">${jndiUrl}</prop>
<prop key="java.naming.factory.initial">${jndiInitial}</prop>
</props>
</property>
</bean>
java中使用:
javax.naming.InitialContext ic = new javax.naming.InitialContext();
weblogic.jdbc.common.internal.RmiDataSource dataSource =
(weblogic.jdbc.common.internal.RmiDataSource)ic.lookup("DataSource");
Connection conn = dataSource.getConnection();
conn.setAutoCommit(false);