Interface DataSource

public interface DataSource

DataSource objects create Connection objects. The data source and its connections don’t participate in distributed transactions. See XADataSource and XAConnection instead for distributed transaction support.

Methods

getConnection

public java.sql.Connection getConnection() throws java.sql.SQLException 

This tries to establish a database connection using the default login and password for the data source. You can use getConnection(String user, String password) to provide another login/password pair if needed. A SQLException is thrown if a database access error occurs.

Returns: A Connection to the database

getConnection

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

This tries to establish a database connection using the login/password pair provided as parameters to getConnection. A SQLException is thrown if a database access error occurs.

Parameters:

user:

The database user’s login used to connect to the database

password:

The user’s password

Returns: A Connection to the database

getLoginTimeout

public int getLoginTimeout() throws java.sql.SQLException

This returns the login time-out. A SQLException is thrown if a database access error occurs.

Returns: The maximum amount of time for the connection

getLogWriter

public java.io.PrintWriter getLogWriter() throws java.sql.SQLException

This gets a character output stream used for logging and tracing. A SQLException is thrown if a database access error occurs.

Returns: The log writer for this data source or null when there is no log writer available

setLoginTimeout

public void setLoginTimeout(int seconds) throws java.sql.SQLException

This provides the maximum time that the data source will wait while attempting to connect to a database. The units are seconds. Zero means that either the database driver internal time-out value is used here at the client side or there is no time-out. A SQLException is thrown if a database access error occurs.

Parameters:

seconds:

The maximum amount of time for the connection

setLogWriter

public void setLogWriter(java.io.PrintWriter out) throws java.sql.SQLException

This sets the log writer for the data source. A SQLException is thrown if a database access error occurs.

Parameters:

out:

The new log writer for the data source or null if there is no need to provide a log writer



JDBC 3. 0. JAVA Database Connectivity
JDBC 3: Java Database Connectivity
ISBN: 0764548751
EAN: 2147483647
Year: 2002
Pages: 148

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net