FileDocCategorySizeDatePackage
DarwinsDataSource.javaAPI DocExample2121Sun Jun 22 19:19:10 BST 2003None

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.3 2003/06/22 23:19:09 ian Exp $

Fields Summary
protected String
driverName
The SQL driver name.
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;
		}
	
		Connection c = DriverManager.getConnection(dbURL, userName, passWord);

		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);