Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 63695 invoked from network); 22 Jun 2008 22:06:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Jun 2008 22:06:43 -0000 Received: (qmail 43530 invoked by uid 500); 22 Jun 2008 22:06:38 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 43509 invoked by uid 500); 22 Jun 2008 22:06:38 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 43498 invoked by uid 99); 22 Jun 2008 22:06:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 22 Jun 2008 15:06:38 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of clinton.begin@gmail.com designates 209.85.198.243 as permitted sender) Received: from [209.85.198.243] (HELO rv-out-0708.google.com) (209.85.198.243) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 22 Jun 2008 22:05:47 +0000 Received: by rv-out-0708.google.com with SMTP id b17so6993302rvf.36 for ; Sun, 22 Jun 2008 15:06:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=P7vMSgyXOT0HKkOPa0hb8DTADoeT0ko+q4uVBqMFeYk=; b=HS08c7JEJX4R8h+rKhFYfsDOcSvaihTUOT7OLoUXy0DIaupy+g6qnT5FevCedF4N8f 9ADFF7L+i5Agrf7bvPqTsl3/IvjX1AQmeU6YEjn8KZDxFRn+5Y+gPUozc06/XpYqaoFX ndpKiewKUS2j/ICPpaHpPoLvnoQXgItxkQMmk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=XY1Ch+6xs0vX6X/Uib94hhhX6spbMKdh2GI3h9FKcdlRGuVeIGgEpg6QbTjMP8aoHS jHCzu1D1WMd1qMQEUHDI0/wQbq5VQ6weQUcsKQOkgYCGz0is0RItAwMtLN32lKlsalw/ h8TlzF18xFpcGpm356/bocc4Z1WqsLZdQjLvY= Received: by 10.141.122.20 with SMTP id z20mr11585367rvm.160.1214172366601; Sun, 22 Jun 2008 15:06:06 -0700 (PDT) Received: by 10.114.135.10 with HTTP; Sun, 22 Jun 2008 15:06:06 -0700 (PDT) Message-ID: <16178eb10806221506h11f38100tf7f72576973bc311@mail.gmail.com> Date: Sun, 22 Jun 2008 16:06:06 -0600 From: "Clinton Begin" To: user-java@ibatis.apache.org Subject: Re: Changing the Database at runtime In-Reply-To: <20080622205755.136140@gmx.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <20080622192101.37520@gmx.net> <16178eb10806221253n173756fegeb6984aa59b3722a@mail.gmail.com> <20080622200453.37510@gmx.net> <16178eb10806221315r21bc5665gae69a7c744d5cc1f@mail.gmail.com> <20080622205755.136140@gmx.net> X-Virus-Checked: Checked by ClamAV on apache.org If you think it's a bug, zip up a failing unit test and attach it to a JIRA request. Cheers, Clinton On Sun, Jun 22, 2008 at 2:57 PM, Wolf-Dieter Mische wrote: > hm... currently I separated the creation in a parameterless function and = getting the same result. before I calling the function I do this: > ((SimpleDataSource)sqlMap.getDataSource()).forceCloseAll(); > sqlMap =3D null; > System.gc(); > createNewInstance(); > > The logging says: SimpleDataSource forcefully closed/removed all connecti= ons. > > So it looks like that the connections are closed. There must be some rema= ining object in ibatis. > > > greetz > wolle > > -------- Original-Nachricht -------- >> Datum: Sun, 22 Jun 2008 14:15:57 -0600 >> Von: "Clinton Begin" >> An: user-java@ibatis.apache.org >> Betreff: Re: Changing the Database at runtime > >> It does pool connections, but it's per SqlMapClient instance, so: >> >> sqlMap =3D SqlMapClientBuilder.buildSqlMapClient(reader, props); >> >> Would result in a new instance that had its own connection pool. >> Nothing magical here... so double check that you're using the right >> instance everywhere. >> >> One other thing though, this isn't an intended use for iBATIS -- to be >> creating SqlMapClient instances like this. You might want to force >> close all of the connections from the pool. If you're using >> SimpleDataSource, you can do so like this: >> >> ((SimpleDataSource)sqlMap.getDataSource()).forceCloseAll(); >> >> Clinton >> >> On Sun, Jun 22, 2008 at 2:04 PM, Wolf-Dieter Mische wrot= e: >> > It doesn't work. I also tried it with a second properties file. It see= ms >> 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" >> >> An: user-java@ibatis.apache.org >> >> Betreff: Re: Changing the Database at runtime >> > >> >> Properties props =3D 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 >> wrote: >> >> > Hello, >> >> > >> >> > in my current project I have to change the database at runtime. Doe= s >> >> 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 =3D "com/mydom/ibatis.properties"; >> >> > Properties props =3D >> Resources.getResourceAsProperties(propfile); >> >> > >> >> > String sqlmap =3D "./src/com/mydom/SqlMapConfig.xml"; >> >> > Reader reader =3D new FileReader(sqlmap); >> >> > SqlMapClient sqlMap =3D >> >> SqlMapClientBuilder.buildSqlMapClient(reader, props); >> >> > >> >> > //doing some inserts, etc. >> >> > >> >> > props.setProperty("url", >> >> "jdbc:mysql://localhost:3306/otherdatabase"); >> >> > sqlMap =3D SqlMapClientBuilder.buildSqlMapClient(reader, pro= ps); >> >> > >> >> > //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=3Dsv_ext_mf@gmx >> >> > >> > >> > -- >> > Psssst! Schon vom neuen GMX MultiMessenger geh=F6rt? >> > Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger >> > > > -- > Psssst! Schon vom neuen GMX MultiMessenger geh=F6rt? > Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger >