com.elvyx
Class DataSource

java.lang.Object
  extended by com.elvyx.DataSource
All Implemented Interfaces:
java.io.Serializable, javax.naming.Referenceable, javax.sql.DataSource
Direct Known Subclasses:
ConnectionPoolDataSource, XADataSource

public class DataSource
extends java.lang.Object
implements javax.sql.DataSource, javax.naming.Referenceable, java.io.Serializable

DataSource wrapper

Since:
1.0
Version:
$Revision: 1.3 $
Author:
David Newcomb
See Also:
Serialized Form

Field Summary
protected  java.util.Properties dsProperties
          The driver to create connections with
protected  java.io.PrintWriter logWriter
          Log stream
 
Constructor Summary
DataSource()
          Default no-arg constructor for Serialization Load defaults
 
Method Summary
 java.sql.Connection getConnection()
          Creates a new connection using the already configured username and password.
protected  java.sql.Connection getConnection(java.util.Properties props)
          Creates a connection using the specified properties.
 java.sql.Connection getConnection(java.lang.String userID, java.lang.String password)
          Creates a new connection with the given username and password
 int getLoginTimeout()
          Returns the login timeout
 java.io.PrintWriter getLogWriter()
          Returns the log writer for this data source
 javax.naming.Reference getReference()
          Required method to support this class as a Referenceable.
 void setLoginTimeout(int seconds)
           
 void setLogWriter(java.io.PrintWriter output)
          Sets the log writer for this data source.
 void setPassword(java.lang.String pass)
          Sets the password
 void setPort(int p)
          Sets the database port.
 void setPortNumber(int p)
          Sets the port number
 void setProperty(java.lang.String key, java.lang.String value)
           
 void setRealDriver(java.lang.String drv)
           
 void setRealUrl(java.lang.String url)
           
 void setUser(java.lang.String userID)
          Sets the user ID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dsProperties

protected java.util.Properties dsProperties
The driver to create connections with


logWriter

protected java.io.PrintWriter logWriter
Log stream

Constructor Detail

DataSource

public DataSource()
Default no-arg constructor for Serialization Load defaults

Method Detail

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Creates a new connection using the already configured username and password.

Specified by:
getConnection in interface javax.sql.DataSource
Returns:
a connection to the database
Throws:
java.sql.SQLException - if an error occurs

getConnection

public java.sql.Connection getConnection(java.lang.String userID,
                                         java.lang.String password)
                                  throws java.sql.SQLException
Creates a new connection with the given username and password

Specified by:
getConnection in interface javax.sql.DataSource
Parameters:
userID - the user id to connect with
password - the password to connect with
Returns:
a connection to the database
Throws:
java.sql.SQLException - if an error occurs

setLogWriter

public void setLogWriter(java.io.PrintWriter output)
                  throws java.sql.SQLException
Sets the log writer for this data source.

Specified by:
setLogWriter in interface javax.sql.DataSource
Throws:
java.sql.SQLException
See Also:
DataSource.setLogWriter(PrintWriter)

getLogWriter

public java.io.PrintWriter getLogWriter()
Returns the log writer for this data source

Specified by:
getLogWriter in interface javax.sql.DataSource
Returns:
the log writer for this data source

setLoginTimeout

public void setLoginTimeout(int seconds)
                     throws java.sql.SQLException
Specified by:
setLoginTimeout in interface javax.sql.DataSource
Throws:
java.sql.SQLException

getLoginTimeout

public int getLoginTimeout()
Returns the login timeout

Specified by:
getLoginTimeout in interface javax.sql.DataSource
Returns:
the login timeout

setPassword

public void setPassword(java.lang.String pass)
Sets the password

Parameters:
pass - the password

setPort

public void setPort(int p)
Sets the database port.

Parameters:
p - the port

setPortNumber

public void setPortNumber(int p)
Sets the port number

Parameters:
p - the port
See Also:
setPort(int)

getReference

public javax.naming.Reference getReference()
                                    throws javax.naming.NamingException
Required method to support this class as a Referenceable.

Specified by:
getReference in interface javax.naming.Referenceable
Returns:
a Reference to this data source
Throws:
javax.naming.NamingException - if a JNDI error occurs

setRealUrl

public void setRealUrl(java.lang.String url)
Parameters:
url - url to be used within driver.connect

setRealDriver

public void setRealDriver(java.lang.String drv)
Parameters:
url - url to be used within driver.connect

setUser

public void setUser(java.lang.String userID)
Sets the user ID.

Parameters:
userID - the User ID

getConnection

protected java.sql.Connection getConnection(java.util.Properties props)
                                     throws java.sql.SQLException
Creates a connection using the specified properties.

Parameters:
props - the properties to connect with
Returns:
a connection to the database
Throws:
java.sql.SQLException - if an error occurs

setProperty

public void setProperty(java.lang.String key,
                        java.lang.String value)


Copyright © 2006-2008 Armando Perdomo. All Rights Reserved.