ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wolf-Dieter Mische" <Mis...@gmx.at>
Subject Re: Changing the Database at runtime
Date Sun, 22 Jun 2008 20:04:53 GMT
It doesn't work. I also tried it with a second properties file. It seems to me that ibatis
caches the connection or something.

Any other suggestions?

greetz 
wolle


-------- Original-Nachricht --------
> Datum: Sun, 22 Jun 2008 13:53:16 -0600
> Von: "Clinton Begin" <clinton.begin@gmail.com>
> An: user-java@ibatis.apache.org
> Betreff: Re: Changing the Database at runtime

>  Properties props = Resources.getResourceAsProperties(propfile);
> 
> That line uses the classloader to load the props file.   It's likely
> caching the first time you load it.
> 
> Try using a FileReader instead.
> 
> Clinton
> 
> On Sun, Jun 22, 2008 at 1:21 PM, Wolf-Dieter Mische <Mische@gmx.at> wrote:
> > Hello,
> >
> > in my current project I have to change the database at runtime. Does
> anybody do this before? I found some information on spring and ibatis, but in
> my case I have a simple java application.
> >
> > I tried it with changing a properties file and creating a new
> SqlMapClient, but he always uses the old database.
> >
> > heres my code:
> >
> >        String propfile = "com/mydom/ibatis.properties";
> >        Properties props = Resources.getResourceAsProperties(propfile);
> >
> >        String sqlmap = "./src/com/mydom/SqlMapConfig.xml";
> >        Reader reader = new FileReader(sqlmap);
> >        SqlMapClient sqlMap =
> SqlMapClientBuilder.buildSqlMapClient(reader, props);
> >
> >        //doing some inserts, etc.
> >
> >        props.setProperty("url",
> "jdbc:mysql://localhost:3306/otherdatabase");
> >        sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader, props);
> >
> >        //doing some inserts, etc
> >
> > Any ideas?
> >
> > greetz
> > wolle
> > --
> > GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen!
> > Jetzt dabei sein: http://www.shortview.de/?mc=sv_ext_mf@gmx
> >

-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger

Mime
View raw message