org.enhydra.jdbc.standard
Class StandardDataSource

java.lang.Object
  extended by org.enhydra.jdbc.util.JdbcUtil
      extended by org.enhydra.jdbc.core.CoreDataSource
          extended by org.enhydra.jdbc.standard.StandardDataSource
All Implemented Interfaces:
java.io.Serializable, javax.naming.Referenceable, javax.naming.spi.ObjectFactory, javax.sql.DataSource
Direct Known Subclasses:
IdbDataSource, StandardConnectionPoolDataSource

public class StandardDataSource
extends CoreDataSource
implements javax.sql.DataSource

Provides a Data Source which can be used to generate JDBC connections.

This class is generic in the sense that it does not rely upon anything other than standard Java APIs. It uses java.sql.DriverManager and preconfigured properties to construct a JDBC connection. Important : networkProtocol, portNumber, serverName are not used. Please use instead the url property.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.enhydra.jdbc.core.CoreDataSource
logWriter, password, user
 
Fields inherited from class org.enhydra.jdbc.util.JdbcUtil
log
 
Constructor Summary
  StandardDataSource()
          Constructors
protected StandardDataSource(java.sql.Driver drv)
           
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 java.sql.Connection getConnection()
           
 java.sql.Connection getConnection(java.lang.String u, java.lang.String p)
           
 java.lang.String getDriverName()
          return the name of the driver
 java.lang.Object getObjectInstance(java.lang.Object refObj, javax.naming.Name name, javax.naming.Context nameCtx, java.util.Hashtable env)
          Methods inherited from ObjectFactory
 javax.naming.Reference getReference()
          Methods inherited from referenceable
 int getTransactionIsolation()
          return the transaction isolation level defined for the current database
 java.lang.String getUrl()
          return the url of the database
 int hashCode()
           
 void setDriverName(java.lang.String driverName)
          set the name of the jdbc driver
 void setTransactionIsolation(int level)
          set the level of the transaction isolation for the current database
 void setUrl(java.lang.String url)
          set the database url
 java.lang.String toString()
           
 
Methods inherited from class org.enhydra.jdbc.core.CoreDataSource
getDescription, getLoginTimeout, getLogWriter, getPassword, getThreadFactory, getUser, isDebug, isVerbose, setDebug, setDescription, setLoginTimeout, setLogWriter, setPassword, setThreadFactory, setUser, setVerbose, shutdown
 
Methods inherited from class org.enhydra.jdbc.util.JdbcUtil
setLogger
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.sql.DataSource
getLoginTimeout, getLogWriter, setLoginTimeout, setLogWriter
 

Constructor Detail

StandardDataSource

public StandardDataSource()
Constructors


StandardDataSource

protected StandardDataSource(java.sql.Driver drv)
                      throws java.sql.SQLException
Throws:
java.sql.SQLException
Method Detail

getDriverName

public java.lang.String getDriverName()
return the name of the driver

Returns:
the string representation of the driver name

getUrl

public java.lang.String getUrl()
return the url of the database

Returns:
the string representation of the database url

setDriverName

public void setDriverName(java.lang.String driverName)
                   throws java.sql.SQLException
set the name of the jdbc driver

Parameters:
driverName - the string representation of the jdbc driver name
Throws:
java.sql.SQLException

setUrl

public void setUrl(java.lang.String url)
set the database url

Parameters:
url - the string representation of the database url

setTransactionIsolation

public void setTransactionIsolation(int level)
set the level of the transaction isolation for the current database

Parameters:
level - the integer level

getTransactionIsolation

public int getTransactionIsolation()
return the transaction isolation level defined for the current database

Returns:
the transaction isolation level

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Specified by:
getConnection in interface javax.sql.DataSource
Returns:
Throws:
java.sql.SQLException

getConnection

public java.sql.Connection getConnection(java.lang.String u,
                                         java.lang.String p)
                                  throws java.sql.SQLException
Specified by:
getConnection in interface javax.sql.DataSource
Parameters:
u -
p -
Returns:
Throws:
java.sql.SQLException

getReference

public javax.naming.Reference getReference()
                                    throws javax.naming.NamingException
Methods inherited from referenceable

Specified by:
getReference in interface javax.naming.Referenceable
Overrides:
getReference in class CoreDataSource
Throws:
javax.naming.NamingException

getObjectInstance

public java.lang.Object getObjectInstance(java.lang.Object refObj,
                                          javax.naming.Name name,
                                          javax.naming.Context nameCtx,
                                          java.util.Hashtable env)
                                   throws java.lang.Exception
Methods inherited from ObjectFactory

Specified by:
getObjectInstance in interface javax.naming.spi.ObjectFactory
Overrides:
getObjectInstance in class CoreDataSource
Throws:
java.lang.Exception

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class CoreDataSource

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object