Both of these suggestions are connection pooling datasources; or do they
also provide a simple datasource? Jakarta Commons already has DBCP which
offers a couple connection pooling datasources, no need to go looking to
sourceforge.
John McNally
David Graham wrote:
Why not just use a real DataSource from C3P0 or Proxool? They're fully
featured and easy to setup. Also, we should not use properties named
jdbc.* as they are potentially used by drivers.
http://sourceforge.net/projects/c3p0
http://proxool.sourceforge.net/
David
--- Henri Yandell <[EMAIL PROTECTED]> wrote:
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 = System.getProperty("jdbc.driver");
private String username = System.getProperty("jdbc.user");
private String password = System.getProperty("jdbc.password");
private String uri = 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();
}
}
Get Firefox!
http://www.mozilla.org/firefox/
____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]