Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

org.objectweb.cjdbc.driver.DataSource Class Reference

Collaboration diagram for org.objectweb.cjdbc.driver.DataSource:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 DataSource ()
java.sql.Connection getConnection () throws SQLException
java.sql.Connection getConnection (String user, String password) throws SQLException
void setLogWriter (PrintWriter output) throws SQLException
java.io.PrintWriter getLogWriter ()
void setLoginTimeout (int seconds) throws SQLException
int getLoginTimeout () throws SQLException
Reference getReference () throws NamingException
String getDescription ()
void setUrl (String url)
void setURL (String url)
String getUrl ()
String getURL ()
void setUser (String userName)
String getUser ()
void setPassword (String pwd)

Protected Member Functions

java.sql.Connection getConnection (Properties props) throws SQLException

Protected Attributes

String url = null
String user = null
String password = null
PrintWriter logWriter = null

Static Protected Attributes

final String URL_PROPERTY = "url"
final String USER_PROPERTY = Driver.USER_PROPERTY
final String PASSWORD_PROPERTY = Driver.PASSWORD_PROPERTY
final String DRIVER_CLASSNAME = "org.objectweb.cjdbc.driver.Driver"
final String FACTORY_CLASSNAME = "org.objectweb.cjdbc.driver.DataSourceFactory"
final String DESCRIPTION_PROPERTY = "description"
Driver driver = null

Static Package Functions

 [static initializer]

Detailed Description

An implementation of the JDBC 2.0 optional package DataSource interface. It allows to set the URL, user name, and password to its properties. It can be bound via JNDI so that the properties can be set by an "application server" and a "ready-to-use" reference to DataSource can be retrieved via JNDI.

Author:
Marek Prochazka
Version:
1.0

Definition at line 47 of file DataSource.java.


Constructor & Destructor Documentation

org.objectweb.cjdbc.driver.DataSource.DataSource  ) 
 

Default constructor.

Definition at line 85 of file DataSource.java.

00086   {
00087   }


Member Function Documentation

java.sql.Connection org.objectweb.cjdbc.driver.DataSource.getConnection Properties  props  )  throws SQLException [protected]
 

Creates a connection using the specified properties.

Parameters:
props connection properties.
Exceptions:
SQLException if an error occurs.
Returns:
a new connection.

Definition at line 302 of file DataSource.java.

References org.objectweb.cjdbc.driver.Driver.connect(), org.objectweb.cjdbc.driver.DataSource.driver, and org.objectweb.cjdbc.driver.DataSource.url.

00304   {
00305     return driver.connect(url, props);
00306   }

java.sql.Connection org.objectweb.cjdbc.driver.DataSource.getConnection String  user,
String  password
throws SQLException
 

Gets connection. Retrieves a new connection using the user name and password specified.

Parameters:
user user name.
password password.
Returns:
a new connection.
Exceptions:
SQLException if an error occurs.

Definition at line 113 of file DataSource.java.

References org.objectweb.cjdbc.driver.DataSource.getConnection().

00115   {
00116     if (user == null)
00117     {
00118       user = "";
00119     }
00120     if (password == null)
00121     {
00122       password = "";
00123     }
00124     Properties props = new Properties();
00125     props.put(USER_PROPERTY, user);
00126     props.put(PASSWORD_PROPERTY, password);
00127 
00128     return getConnection(props);
00129   }

java.sql.Connection org.objectweb.cjdbc.driver.DataSource.getConnection  )  throws SQLException
 

Gets connection. Retrieves a new connection using the user name and password that have been already set.

Exceptions:
SQLException if an error occurs.
Returns:
a new connection.

Definition at line 99 of file DataSource.java.

Referenced by org.objectweb.cjdbc.driver.DataSource.getConnection().

00100   {
00101     return getConnection(user, password);
00102   }

String org.objectweb.cjdbc.driver.DataSource.getDescription  ) 
 

Return the description of this Datasource with the Driver version number.

Returns:
Datasource description

Definition at line 202 of file DataSource.java.

References org.objectweb.cjdbc.driver.DataSource.driver, org.objectweb.cjdbc.driver.Driver.getMajorVersion(), and org.objectweb.cjdbc.driver.Driver.getMinorVersion().

Referenced by org.objectweb.cjdbc.driver.DataSource.getReference().

00203   {
00204     return "C-JDBC " + driver.getMajorVersion() + "."
00205         + driver.getMinorVersion() + " Datasource";
00206   }

int org.objectweb.cjdbc.driver.DataSource.getLoginTimeout  )  throws SQLException
 

Gets the login timeout.

Returns:
login timeout
Exceptions:
SQLException in case of an error occurs.

Definition at line 168 of file DataSource.java.

00169   {
00170     return 0;
00171   }

java.io.PrintWriter org.objectweb.cjdbc.driver.DataSource.getLogWriter  ) 
 

Gets the log writer.

Returns:
log writer.

Definition at line 147 of file DataSource.java.

00148   {
00149     return logWriter;
00150   }

Reference org.objectweb.cjdbc.driver.DataSource.getReference  )  throws NamingException
 

Gets a reference to this. The factory used for this class is the DataSourceFactoryclass.

Returns:
a reference to this.
Exceptions:
NamingException if DataSourceFactory not found.

Definition at line 183 of file DataSource.java.

References org.objectweb.cjdbc.driver.DataSource.getDescription(), org.objectweb.cjdbc.driver.DataSource.getUrl(), org.objectweb.cjdbc.driver.DataSource.getUser(), and org.objectweb.cjdbc.driver.DataSource.URL_PROPERTY.

00184   {
00185     Reference ref = new Reference(getClass().getName(), FACTORY_CLASSNAME, null);
00186     ref.add(new StringRefAddr(DESCRIPTION_PROPERTY, getDescription()));
00187     ref.add(new StringRefAddr(USER_PROPERTY, getUser()));
00188     ref.add(new StringRefAddr(PASSWORD_PROPERTY, password));
00189     ref.add(new StringRefAddr(URL_PROPERTY, getUrl()));
00190     return ref;
00191   }

String org.objectweb.cjdbc.driver.DataSource.getURL  ) 
 

Gets URL of the C-JDBC controller(s) to connect. The URL is stored in the URL_PROPERTYproperty.

Returns:
URL to be used to connect C-JDBC controller(s).

Definition at line 249 of file DataSource.java.

References org.objectweb.cjdbc.driver.DataSource.getUrl().

00250   {
00251     return getUrl();
00252   }

String org.objectweb.cjdbc.driver.DataSource.getUrl  ) 
 

Gets url of the C-JDBC controller(s) to connect. The URL is stored in the URL_PROPERTYproperty.

Returns:
URL to be used to connect C-JDBC controller(s).

Definition at line 238 of file DataSource.java.

Referenced by org.objectweb.cjdbc.driver.DataSource.getReference(), and org.objectweb.cjdbc.driver.DataSource.getURL().

00239   {
00240     return url;
00241   }

String org.objectweb.cjdbc.driver.DataSource.getUser  ) 
 

Gets user name to be used to connect the C-JDBC controller(s). The user name is stored in the USER_PROPERTYproperty.

Returns:
user name to be used to connect C-JDBC controller(s).

Definition at line 273 of file DataSource.java.

Referenced by org.objectweb.cjdbc.driver.DataSource.getReference().

00274   {
00275     return user;
00276   }

void org.objectweb.cjdbc.driver.DataSource.setLoginTimeout int  seconds  )  throws SQLException
 

Sets the timeout. Actually does nothing.

Parameters:
seconds timeout in seconds.
Exceptions:
SQLException in case of an error occurs.

Definition at line 158 of file DataSource.java.

00159   {
00160   }

void org.objectweb.cjdbc.driver.DataSource.setLogWriter PrintWriter  output  )  throws SQLException
 

Sets the log writer for this data source.

Parameters:
output print writer.
Exceptions:
SQLException in case of an error occurs.

Definition at line 137 of file DataSource.java.

00138   {
00139     logWriter = output;
00140   }

void org.objectweb.cjdbc.driver.DataSource.setPassword String  pwd  ) 
 

Sets password to be used to connect the C-JDBC controller(s). The method can be used by the "application server" to set the password (potentially according a deployment descriptor). The password is stored in the PASSWORD_PROPERTYproperty. Note that there is not a getPassword method.

Parameters:
pwd password to be used to connect C-JDBC controller(s).

Definition at line 287 of file DataSource.java.

Referenced by org.objectweb.cjdbc.driver.DataSourceFactory.getObjectInstance().

00288   {
00289     password = pwd;
00290   }

void org.objectweb.cjdbc.driver.DataSource.setURL String  url  ) 
 

Sets URL of the C-JDBC controller(s) to connect. The method is used by the "application server" to set the URL (potentially according a deployment descriptor). The URL is stored in the "url" property.

Parameters:
url URL to be used to connect C-JDBC controller(s).

Definition at line 227 of file DataSource.java.

References org.objectweb.cjdbc.driver.DataSource.setUrl().

00228   {
00229     setUrl(url);
00230   }

void org.objectweb.cjdbc.driver.DataSource.setUrl String  url  ) 
 

Sets url of the C-JDBC controller(s) to connect. The method is used by the "application server" to set the URL (potentially according a deployment descriptor). The url is stored in the URL_PROPERTYproperty.

Parameters:
url URL to be used to connect C-JDBC controller(s)

Definition at line 215 of file DataSource.java.

Referenced by org.objectweb.cjdbc.driver.DataSourceFactory.getObjectInstance(), and org.objectweb.cjdbc.driver.DataSource.setURL().

00216   {
00217     this.url = url;
00218   }

void org.objectweb.cjdbc.driver.DataSource.setUser String  userName  ) 
 

Sets user name to be used to connect the C-JDBC controller(s). The method can be used by the "application server" to set the user name (potentially according a deployment descriptor). The user name is stored in the USER_PROPERTYproperty.

Parameters:
userName user name to be used to connect C-JDBC controller(s).

Definition at line 262 of file DataSource.java.

Referenced by org.objectweb.cjdbc.driver.DataSourceFactory.getObjectInstance().

00263   {
00264     user = userName;
00265   }


Member Data Documentation

Driver org.objectweb.cjdbc.driver.DataSource.driver = null [static, protected]
 

Wrapped driver for to get connections.

Definition at line 63 of file DataSource.java.

Referenced by org.objectweb.cjdbc.driver.DataSource.getConnection(), and org.objectweb.cjdbc.driver.DataSource.getDescription().

String org.objectweb.cjdbc.driver.DataSource.url = null [protected]
 

DataSource properties

Definition at line 77 of file DataSource.java.

Referenced by org.objectweb.cjdbc.driver.DataSource.getConnection().

final String org.objectweb.cjdbc.driver.DataSource.URL_PROPERTY = "url" [static, protected]
 

DataSource properties

Definition at line 55 of file DataSource.java.

Referenced by org.objectweb.cjdbc.driver.DataSource.getReference().


The documentation for this class was generated from the following file:
Generated on Mon Apr 11 22:04:58 2005 for C-JDBC by  doxygen 1.3.9.1