我對spring jdbc完全陌生,遇到了需要將spring jdbc配置文件中使用的sql轉換爲plain db2格式的情況。 例如,下面是在spring conf文件中使用的查詢(內部值標記),我想更改爲針對db2運行,我瀏覽了許多spring文檔,但沒有找到任何相關信息,有人能指向我的鏈接或解決這個SQL格式化將Spring jdbc中使用的查詢轉換爲db2
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!-- JNDI DataSource for J2EE environment. -->
<bean id="mi.conv.batch.dataSource" class="org.springframework.jdbc.datasource.WebSphereDataSourceAdapter">
<property name="targetDataSource">
<jee:jndi-lookup id="dataSourceInternal" jndi-name="java:comp/env/jdbc/Database" />
</property>
</bean>
<!-- Transaction manager that delegates to JTA (use it when running within a container) -->
<bean id="mi.conv.batch.TransactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
<!-- Transactional proxy for data access facade. -->
<bean id="mi.conv.batch.transactionProxyParent" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true">
<property name="transactionManager" ref="x.y.z.TransactionManager"/>
<property name="transactionAttributes">
<props>
<prop key="add*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="statementsDao" parent="x.y.z.transactionProxyParent">
<property name="target">
<bean class="abc.test.TestDaoImpl">
<property name="dataSource" ref="a.b.c.dataSource"/>
<property name="insertNotificationPreferenceSql">
<value>
select
NOTIFICATIONKY
from new table (
insert into
NOTIFICATION (
ID,
PERSONKY,
INSTANCEKY
)
**select
(substr(ba.CODE, 1, 2) || '1111' || RIGHT(ba.CODE, 4) ||
(case substr(ba.CODE, 1, 2)
when 'XY' then ''
else '2222'
end)
|| '0000' || ba.ACCTID) as ID,
cp.PERSONKY,
ba.INSTANCEKY
from
BCSACCT ba
join
PERSON cp on (1=1)
where cp.PERSONKY = :personId
and ba.INSTANCEKY = :prodinstId**
)
</value>
</property>
</bean>
</property>
</bean>
</beans>
值標記中的查詢是DB2 SQL。 – 2014-10-16 16:18:12
您對DB2以外的數據庫使用了相同的SQL嗎?如果你需要一個SQL語句用於DB2,而另一個用於另一個數據庫,則必須單獨複製Spring XML配置文件並維護這些語句,除非您使用的是支持配置文件的較新的Spring,在這種情況下,您可以應用每個「」的配置文件名稱需要某些特定於DB2的內容。 –
ngreen
2014-10-16 20:19:04
沒有它的單個數據庫,謝謝澄清它澄清了我所有的事情 – Rakesh 2014-10-17 05:57:01