我正在使用spring开发一个与informix数据库一起工作的应用程序,它正在tomcat上运行。数据源的配置在应用程序中完成,如下所示:
/myapp/meta-inf/context.xml
<Context path="/MyApp"
reloadable="false"
cachingAllowed="false" >
<Resource name="jdbc/MyAppDS"
auth="Container" type="javax.sql.DataSource"
driverClassName="com.informix.jdbc.IfxDriver"
url="jdbc:informix-sqli://app.prod.com:22222/prod:informixserver=prodshm;IFX_LOCK_MODE_WAIT=20;IFX_XASPEC=Y;"
username="user" password="password"
maxActive="100" maxIdle="25" maxWait="10000"
removeAbandoned="true" removeAbandonedTimeout="60" logAbandoned="true"/>
</Context>
/myapp/web-inf/web.xml
…
<resource-ref>
<res-ref-name>jdbc/MyAppDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/config/applicationContext.xml
/WEB-INF/config/dataAccessContext.xml
</param-value>
</context-param>
…
/myapp/config/dataaccesscontext.xml
<beans>
<import resource="dataSource-def.xml"/>
<bean id="scriptDao" parent="txProxyTemplate">
<property name="target">
<bean class="com.myapp.script.ScriptDaoJdbc">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
</bean>
</property>
</bean>
…
</beans>
/myapp/config/datasource-def.xml文件
<beans>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName"><value>java:/comp/env/jdbc/MyAppDS</value></property>
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
</bean>
</beans>
似乎context.xml中的参数ifx\u lock\u mode\u wait不起作用,因为我有很多锁错误,例如:
error code [-244]; Could not do a physical-order read to fetch next row.; ISAM error: record is locked.
error code [-245]; Could not position within a file via an index.; ISAM error: key value locked
为了检查我的假设是否正确,我开始在每个有问题的查询之前显式发送“set lock mode to wait 20”,并且可以看到它工作了——不再有错误消息。
context.xml的先前配置如下所示,也不起作用:
/myapp/meta-inf/context.xml(早期版本)
<Context path="/MyApp"
reloadable="false"
cachingAllowed="false" >
<Resource name="jdbc/MyAppDS"
auth="Container" type="javax.sql.DataSource"
driverClassName="com.informix.jdbc.IfxDriver"
url="jdbc:informix-sqli://app.prod.com:22222/prod:informixserver=prodshm"
username="user" password="password"
maxActive="100" maxIdle="25" maxWait="10000"
removeAbandoned="true" removeAbandonedTimeout="60" logAbandoned="true"
connectionProperties="ifxIFX_LOCK_MODE_WAIT=20;ifxIFX_XASPEC=Y;" />
</Context>
为什么这个声明 IFX_LOCK_MODE_WAIT=20
在context.xml中不起作用?还有什么更好的方法来实现这一点呢?
谢谢您!
暂无答案!
目前还没有任何答案,快来回答吧!