i know jta can support multiple datasource. but the performance is bad, and also need datasource to support it.
in my old project, we just use pure jdbc to handle multiple datasource(in fact , they are two oracle database)
the old code style is
Connection conn1=null;
Connection conn2=null;
try{
conn1=DataSource1.getConn();
conn2=DataSource2.getConn();
........
conn1.commit();--------(1)
conn2.commit();--------(2)
}catch{
conn1.rollback();
conn2.rollback();
}finally{
cleanUp(conn1..);
cleanUP(conn2...)
}
in this old code style, only fail happen between (1) and (2) will cause the data not consistent. but since the two data base all in our local area network. so it few happen. In fact. we think it is ok. no need JTA.
but now if we use Spring jdbc declare transaction. we find the framework can not reach the goal as the old code style.
In fact, the Spring Jdbc 's simulant code style is below
Connection conn1=null;
Connection conn2=null;
try{
conn1=DataSource1.getConn();
...... --------use conn1 do someting
try{
conn2=DataSource2.getConn();
.....................use conn2 do someting
conn2.commit();--------(1)
}catch(e){
conn2.rollback()
}finally{
clean up conn2
}
........----------- still use conn1 do thing
conn1.commit();--------(2)
}catch{
conn2.rollback();
}finally{
cleanUP(conn2...)
}
to compare the two code style, you will find the Spring jdbc framework will more easy cause the data not consistent. how to make Spring generate code like the first code style.
we would not want to use jca,since the two database both in our company.
we think the code style(1) is enough. but we want to use Spring jdbc framework.
who can help me.
my email is :qilong2000@hotmail.com. if you think the mail is better communication fashion, you can send mail to me


Reply With Quote
