Hi,

Thanks for that tip. My other dilemma is that I normally would use spring ibatis configuration but hat works fine when I generally have a single connection to a known database e.g.

<bean id="dataSource1" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
       <property name="driverClassName" value="${jdbc1.driverClassName}"/>
       <property name="url" value="${jdbc1.url}"/>
       <property name="username" value="${jdbc1.username}"/>
       <property name="password" value="${jdbc1.password}"/>
   </bean>

<bean id="sqlMapClient1" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <property name="configLocation" value="classpath:/conf/sqlmap1-config.xml"/>
       <property name="dataSource" ref="dataSource1"/>
   </bean>

<bean id="testService" class="org.novotny.services.impl.ibatis.TestServiceImpl">
       <property name="sqlMapClient" ref="sqlMapClient1"/>
   </bean>

In my current situation, I have an unknown number of databases that I can determine from the INFORMATION_SCHEMA and they all have the same table structure-- so I then need to presumably (re)create 10 different BasicDataSource's with 10 SqlMapClients (and apparently 10 testServices as well) (basically rejigger the sqlMapClient and BasicDataSource initially loaded by spring) (I don't need all 10 at once-- I can create each of the dataSource, sqlMapClient, testService one at a time for each of the databases). Any thoughts on how to do this? It sounds pretty painful since it seems Spring is best suited for static configuration...

   Thanks again, Jason

Toby Thain wrote:

On 24-Jun-08, at 10:45 PM, Jason Novotny wrote:


Hi,

I'm converting a nasty python script to java and they use the database metadata to determine the list of databases (the equivalent of a "show databases;" MySql command) and then connect to the appropriate one before querying on tables. Is there a way to do this using iBatis?

You can use MySQL's INFORMATION_SCHEMA.

--Toby


   Thanks, Jason

Reply via email to