FileDocCategorySizeDatePackage
DarwinsDataSource.javaAPI DocExample2304Sat Jan 13 18:09:52 GMT 2001None

DarwinsDataSource

public class DarwinsDataSource extends Object implements Serializable, Remote, DataSource
A simple DataSource wrapper for a JDBC connection. Constructed using a drivername and dbURL
version
$Id: DarwinsDataSource.java,v 1.1 2001/01/13 23:09:52 ian Exp $

Fields Summary
protected String
driverName
The SQL driver name. We cannot load the driver itself as we cannot ensure that all Drivers will be Serializable.
protected String
dbURL
The Database URL
protected PrintWriter
logWriter
The LogWriter - not the same as DriverManager.getLogWriter
Constructors Summary
public DarwinsDataSource(String driverName, String dbURL)

		this.driverName = driverName;
		this.dbURL = dbURL;
	
Methods Summary
public java.sql.ConnectiongetConnection()
Attempt to establish a database connection using defaults.

		return getConnection(null, null);
	
public java.sql.ConnectiongetConnection(java.lang.String userName, java.lang.String passWord)
Attempt to establish a database connection using the given username and password as credentials.


		try {
			Class.forName(driverName);
		} catch (ClassNotFoundException e) {
			System.err.println("Can't load driver; check CLASSPATH!");
			return null;
		} catch (Exception ex) {
			System.err.println("Can't load driver: " + ex);
			return null;
		}
		Properties props = new Properties();
		props.setProperty("user", userName);
		props.setProperty("password", passWord);
		Connection c = DriverManager.getConnection(dbURL, props);

		return c;
	
public java.io.PrintWritergetLogWriter()
Get the log writer for this data source.

		return logWriter;
	
public intgetLoginTimeout()
Gets the maximum time in seconds that this data source can wait while attempting to connect to the database.

		return DriverManager.getLoginTimeout();
	
public voidsetLogWriter(java.io.PrintWriter out)
Set the log writer for this data source.

		logWriter = out;
	
public voidsetLoginTimeout(int seconds)
Sets the maximum time in seconds that this data source will wait while attempting to connect to a database.

		DriverManager.setLoginTimeout(seconds);