You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Forest Zhu <fo...@gmail.com> on 2007/04/26 04:39:53 UTC

Fwd: Dynamically specify the connectionURL in buildDaoManager

Hi, all.

My project consists of several database with the same schema, due to the
business reason we could not specify which database should connect in the
sqlmapconfig.xml. So we have to specify the connectionURL on the fly, like

            Properties p = new Properties();
            p.put("username", "username");
            p.put("password", "password");
            p.put("connectionURL", "xxxxxxx");

            DaoManager daom = DaoManagerBuilder.buildDaoManager(reader, p);


But this does not work. From the previous discussions on similar topic, it
seems that dynamically setting the username and password using the above
method works. What about the connectionURL then?

Thanks and best regards.

F.

Re: Fwd: Dynamically specify the connectionURL in buildDaoManager

Posted by Ma...@prolifics.de.
Works very fine for us.

In our sql-map.xml we have an entry like
      <property value="${url}" name="JDBC.ConnectionURL"/>
and pass in a Property-Object with a key named "url" ("connectionURL" in 
your case) and the desired connection url that is build at runtime.

HTH
Marc Heimann
Software Engineer

Prolifics Deutschland GmbH
Notkestr. 3, D-22607 Hamburg
phone +49 (0)40 890 667-70
fax    +49 (0)40 890 667-99
marc.heimann@prolifics.de
SOA... Building the Future into Your Business
Handelsregister: Hamburg, HRB 89903
Geschäftsführer: Ulrich Frotscher


"Forest Zhu" <fo...@gmail.com> wrote on 26.04.2007 04:39:53:

> Hi, all.
> 
> My project consists of several database with the same schema, due to
> the business reason we could not specify which database should 
> connect in the sqlmapconfig.xml. So we have to specify the 
> connectionURL on the fly, like 
> 
>             Properties p = new Properties();
>             p.put("username", "username");
>             p.put("password", "password");
>             p.put("connectionURL", "xxxxxxx"); 
> 
>             DaoManager daom = DaoManagerBuilder.buildDaoManager(reader, 
p);
> 
> 
> But this does not work. From the previous discussions on similar 
> topic, it seems that dynamically setting the username and password 
> using the above method works. What about the connectionURL then? 
> 
> Thanks and best regards.
> 
> F.