views:

117

answers:

1

I have the requirement of updating an app to use multiple (i.e., two in this case) datasources depending upon the type of query. For instance, use DB1 for reads and DB2 for write operations. How would I approach this?

A: 

We've done this by creating two SqlMapClients, one for read-only and one for read-write. Each has its own sqlMapConfig file driving it. We segregate our sqlMap resources into read and write pairs, ie, Account.xml and Account-Write.xml. The read-only sqlMapConfig only loads the read sqlMap resources, while the read-write sqlMapConfig loads both the read and the write resource.

This seems to work out fine. If you are doing a read-only transaction, you use the read-only SqlMapClient, otherwise you use the read-write SqlMapClient.

Jim Ferrans