spring中配置jndi数据源

spring  AplicationContext.xml中的配置

<bean id="dataSource1" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="MySQLTEST"></property>
</bean>

jboss中mysql-ds.xml的配置:

<datasources>
<local-tx-datasource>
<jndi-name>MYSQLTEST</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<use-java-context>false</use-java-context>
<user-name>name</user-name>
<password>password</password>
<check-valid-connection-sql>select 1</check-valid-connection-sql>
<min-pool-size>10</min-pool-size>
<max-pool-size>200</max-pool-size>
<idle-timeout-minutes>30</idle-timeout-minutes>
<background-validation>true</background-validation>
<background-validation-millis>300000</background-validation-millis>
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>

如果按照以上的配置找不到jndi的名称的话在你的spring  aplicationContext.xml文件中的jndi的配置中添加上java:就行了,如下:

<bean id="dataSource1" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:MySQLTEST"></property>
</bean>
上一篇:DelphiXe5中的双向绑定(使用使用TBindScope和TBindExpression,并覆盖AfterConstruction函数)


下一篇:DOS命令行简单用法