Package Summary  Overview Summary

class:DataSource [CHANGED]

  • All Superinterfaces:
    CommonDataSource, Wrapper


                                                    
                                public interface DataSource
    extends CommonDataSource, Wrapper
                                                

    A factory for connections to the physical data source that this DataSource object represents. An alternative to the DriverManager facility, a DataSource object is the preferred means of getting a connection. An object that implements the DataSource interface will typically be registered with a naming service based on the Java™ Naming and Directory (JNDI) API.

    The DataSource interface is implemented by a driver vendor. There are three types of implementations:

    1. Basic implementation -- produces a standard Connection object
    2. Connection pooling implementation -- produces a Connection object that will automatically participate in connection pooling. This implementation works with a middle-tier connection pooling manager.
    3. Distributed transaction implementation -- produces a Connection object that may be used for distributed transactions and almost always participates in connection pooling. This implementation works with a middle-tier transaction manager and almost always with a connection pooling manager.

    A DataSource object has properties that can be modified when necessary. For example, if the data source is moved to a different server, the property for the server can be changed. The benefit is that because the data source's properties can be changed, any code accessing that data source does not need to be changed.

    A driver that is accessed via a DataSource object does not register itself with the DriverManager. Rather, a DataSource object is retrieved thoughthrough a lookup operation and then used to create a Connection object. With a basic implementation, the connection obtained through a DataSource object is identical to a connection obtained through the DriverManager facility.

    An implementation of DataSource must include a public no-arg constructor.

    Since:
    1.4
  • All Superinterfaces:
    CommonDataSource, Wrapper


                                                    
                                public interface DataSource
    extends CommonDataSource, Wrapper
                                                

    A factory for connections to the physical data source that this DataSource object represents. An alternative to the DriverManager facility, a DataSource object is the preferred means of getting a connection. An object that implements the DataSource interface will typically be registered with a naming service based on the Java™ Naming and Directory (JNDI) API.

    The DataSource interface is implemented by a driver vendor. There are three types of implementations:

    1. Basic implementation -- produces a standard Connection object
    2. Connection pooling implementation -- produces a Connection object that will automatically participate in connection pooling. This implementation works with a middle-tier connection pooling manager.
    3. Distributed transaction implementation -- produces a Connection object that may be used for distributed transactions and almost always participates in connection pooling. This implementation works with a middle-tier transaction manager and almost always with a connection pooling manager.

    A DataSource object has properties that can be modified when necessary. For example, if the data source is moved to a different server, the property for the server can be changed. The benefit is that because the data source's properties can be changed, any code accessing that data source does not need to be changed.

    A driver that is accessed via a DataSource object does not register itself with the DriverManager. Rather, a DataSource object is retrieved though a lookup operation and then used to create a Connection object. With a basic implementation, the connection obtained through a DataSource object is identical to a connection obtained through the DriverManager facility.

    An implementation of DataSource must include a public no-arg constructor.

    Since:
    1.4
  • All Superinterfaces:
    CommonDataSource, Wrapper


                                                    
                                public interface DataSource
    extends CommonDataSource, Wrapper
                                                

    A factory for connections to the physical data source that this DataSource object represents. An alternative to the DriverManager facility, a DataSource object is the preferred means of getting a connection. An object that implements the DataSource interface will typically be registered with a naming service based on the Java™ Naming and Directory (JNDI) API.

    The DataSource interface is implemented by a driver vendor. There are three types of implementations:

    1. Basic implementation -- produces a standard Connection object
    2. Connection pooling implementation -- produces a Connection object that will automatically participate in connection pooling. This implementation works with a middle-tier connection pooling manager.
    3. Distributed transaction implementation -- produces a Connection object that may be used for distributed transactions and almost always participates in connection pooling. This implementation works with a middle-tier transaction manager and almost always with a connection pooling manager.

    A DataSource object has properties that can be modified when necessary. For example, if the data source is moved to a different server, the property for the server can be changed. The benefit is that because the data source's properties can be changed, any code accessing that data source does not need to be changed.

    A driver that is accessed via a DataSource object does not register itself with the DriverManager. Rather, a DataSource object is retrieved through a lookup operation and then used to create a Connection object. With a basic implementation, the connection obtained through a DataSource object is identical to a connection obtained through the DriverManager facility.

    An implementation of DataSource must include a public no-arg constructor.

    Since:
    1.4

method:getConnection() [NONE]

  • getConnection

                                                Connection getConnection()
                      throws SQLException
                                            

    Attempts to establish a connection with the data source that this DataSource object represents.

    Returns:
    a connection to the data source
    Throws:
    SQLException - if a database access error occurs
    SQLTimeoutException - when the driver has determined that the timeout value specified by the setLoginTimeout method has been exceeded and has at least tried to cancel the current database connection attempt

method:getConnection(java.lang.String, java.lang.String) [NONE]

  • getConnection

                                                Connection getConnection(java.lang.String username,
                             java.lang.String password)
                      throws SQLException
                                            

    Attempts to establish a connection with the data source that this DataSource object represents.

    Parameters:
    username - the database user on whose behalf the connection is being made
    password - the user's password
    Returns:
    a connection to the data source
    Throws:
    SQLException - if a database access error occurs
    SQLTimeoutException - when the driver has determined that the timeout value specified by the setLoginTimeout method has been exceeded and has at least tried to cancel the current database connection attempt
    Since:
    1.4

method:getLogWriter() [ADDED]

  • getLogWriter

                                                java.io.PrintWriter getLogWriter()throwsSQLException
                                            

    RetrievesthelogwriterforthisDataSourceobject.

    Thelogwriterisacharacteroutputstreamtowhichallloggingandtracingmessagesforthisdatasourcewillbeprinted.Thisincludesmessagesprintedbythemethodsofthisobject,messagesprintedbymethodsofotherobjectsmanufacturedbythisobject,andsoon.Messagesprintedtoadatasourcespecificlogwriterarenotprintedtothelogwriterassociatedwiththejava.sql.DriverManagerclass.WhenaDataSourceobjectiscreated,thelogwriterisinitiallynull;inotherwords,thedefaultisforloggingtobedisabled.

    Specifiedby:
    getLogWriter ininterface CommonDataSource
    Returns:
    thelogwriterforthisdatasourceornullifloggingisdisabled
    Throws:
    SQLException-ifadatabaseaccesserroroccurs
    Since:
    1.4
    SeeAlso:
    CommonDataSource.setLogWriter(java.io.PrintWriter)

method:setLogWriter(java.io.PrintWriter) [ADDED]

  • setLogWriter

                                                void setLogWriter(java.io.PrintWriter out)throwsSQLException
                                            

    SetsthelogwriterforthisDataSourceobjecttothegivenjava.io.PrintWriterobject.

    Thelogwriterisacharacteroutputstreamtowhichallloggingandtracingmessagesforthisdatasourcewillbeprinted.Thisincludesmessagesprintedbythemethodsofthisobject,messagesprintedbymethodsofotherobjectsmanufacturedbythisobject,andsoon.Messagesprintedtoadatasource-specificlogwriterarenotprintedtothelogwriterassociatedwiththejava.sql.DriverManagerclass.WhenaDataSourceobjectiscreatedthelogwriterisinitiallynull;inotherwords,thedefaultisforloggingtobedisabled.

    Specifiedby:
    setLogWriter ininterface CommonDataSource
    Parameters:
    out-thenewlogwriter;todisablelogging,settonull
    Throws:
    SQLException-ifadatabaseaccesserroroccurs
    Since:
    1.4
    SeeAlso:
    CommonDataSource.getLogWriter()

method:setLoginTimeout(int) [ADDED]

  • setLoginTimeout

                                                void setLoginTimeout(int seconds)throwsSQLException
                                            

    Setsthemaximumtimeinsecondsthatthisdatasourcewillwaitwhileattemptingtoconnecttoadatabase.Avalueofzerospecifiesthatthetimeoutisthedefaultsystemtimeoutifthereisone;otherwise,itspecifiesthatthereisnotimeout.WhenaDataSourceobjectiscreated,thelogintimeoutisinitiallyzero.

    Specifiedby:
    setLoginTimeout ininterface CommonDataSource
    Parameters:
    seconds-thedatasourcelogintimelimit
    Throws:
    SQLException-ifadatabaseaccesserroroccurs.
    Since:
    1.4
    SeeAlso:
    CommonDataSource.getLoginTimeout()

method:getLoginTimeout() [ADDED]

  • getLoginTimeout

                                                int getLoginTimeout()throwsSQLException
                                            
    Getsthemaximumtimeinsecondsthatthisdatasourcecanwaitwhileattemptingtoconnecttoadatabase.Avalueofzeromeansthatthetimeoutisthedefaultsystemtimeoutifthereisone;otherwise,itmeansthatthereisnotimeout.WhenaDataSourceobjectiscreated,thelogintimeoutisinitiallyzero.
    Specifiedby:
    getLoginTimeout ininterface CommonDataSource
    Returns:
    thedatasourcelogintimelimit
    Throws:
    SQLException-ifadatabaseaccesserroroccurs.
    Since:
    1.4
    SeeAlso:
    CommonDataSource.setLoginTimeout(int)

method:createConnectionBuilder() [ADDED]