Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 41499 invoked from network); 3 Aug 2005 17:35:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 3 Aug 2005 17:35:47 -0000 Received: (qmail 31848 invoked by uid 500); 3 Aug 2005 17:35:43 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 31787 invoked by uid 500); 3 Aug 2005 17:35:43 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 31772 invoked by uid 99); 3 Aug 2005 17:35:43 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Aug 2005 10:35:43 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=RCVD_BY_IP,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of flamefew@gmail.com designates 64.233.162.207 as permitted sender) Received: from [64.233.162.207] (HELO zproxy.gmail.com) (64.233.162.207) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Aug 2005 10:35:34 -0700 Received: by zproxy.gmail.com with SMTP id l1so108891nzf for ; Wed, 03 Aug 2005 10:35:42 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=e6CwF9TAr6FAQFUQHvSVhUGryPX5rDprQFCjiVxsMpmzWcocGbRZZ5SZj/fXd6bGrfU0Q5lmrSEsps8aZ46XkB0JRJfP8peKOnoFlWjl8ePwWfeJEi/1CXHghx0xlRASaIX47JzSx3tmg6SMOJvwsKAuZovw639N/pZKjCogX/M= Received: by 10.36.158.5 with SMTP id g5mr385163nze; Wed, 03 Aug 2005 10:35:42 -0700 (PDT) Received: by 10.36.13.5 with HTTP; Wed, 3 Aug 2005 10:35:42 -0700 (PDT) Message-ID: <31cc37360508031035112f3b9e@mail.gmail.com> Date: Wed, 3 Aug 2005 13:35:42 -0400 From: Henri Yandell To: Jakarta Commons Developers List Subject: [dbutils] SystemDataSource Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Just had need to hack together a simple DataSource class and wondered if it would fit nicely in dbutils. Name is either SystemDataSource (after SystemClassLoader) or DriverManagerDataSource, it uses Java -D properties and the DriverManager, so is very lightweight and something nice to start with before moving up to a container that supplies a real DataSource. I imagine there are MockDataSources out there that are similar too for unit testing, but nothing in DbUtils yet. (code follows, it's pretty dumb) public class SystemDataSource implements DataSource { private String driver =3D System.getProperty("jdbc.driver"); private String username =3D System.getProperty("jdbc.user"); private String password =3D System.getProperty("jdbc.password"); private String uri =3D System.getProperty("jdbc.uri"); public SystemDataSource() { DbUtils.loadDriver(driver); } public Connection getConnection() throws SQLException { return DriverManager.getConnection(this.uri, this.username, this.password); } public Connection getConnection(String username, String password) throws SQLException { return DriverManager.getConnection(this.uri, username, password); } public PrintWriter getLogWriter() throws SQLException { return DriverManager.getLogWriter(); } public void setLogWriter(PrintWriter logWriter) throws SQLException { DriverManager.setLogWriter(logWriter); } public void setLoginTimeout(int timeout) throws SQLException { DriverManager.setLoginTimeout(timeout); } public int getLoginTimeout() throws SQLException { return DriverManager.getLoginTimeout(); } } --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org