O'Reilly logo

Database Programming with JDBC & Java, Second Edition by George Reese

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

DataSource

Synopsis

Interface Name: javax.sql.DataSource

Superclass: None

Immediate Subclasses: None

Interfaces Implemented: None

Availability: New as of JDK 1.2

Description

This class provides access to a database via JNDI. To get a JDBC connection, you can look up a data source in a JNDI naming or directory service and then grab a connection from that data source.

Class Summary

public interface DataSource {
    java.sql.Connection getConnection( ) 
      throws java.sql.SQLException;
    java.sql.Connection getConnection(String uid, String pw)
      throws java.sql.SQLException;
    int getLoginTimeout( ) throws java.sql.SQLException;
    java.io.PrintWriter getLogWriter( ) 
      throws java.sql.SQLException;
    void setLoginTimeout(int sec) throws java.sql.SQLException;
    void setLogWriter(java.io.PrintWriter pw)
      throws java.sql.SQLException;
}

Object Methods

getConnection( )

public java.sql.Connection getConnection( ) 
  throws java.sql.SQLException;
public java.sql.Connection getConnection(String uid, String pw)
  throws java.sql.SQLException;
Description

These are factory methods for the allocation of a connection to a database from a connection pool.

getLoginTimeout( ) and setLoginTimeout( )

public int getLoginTimeout( ) throws java.sql.SQLException;
public void setLoginTimeout(int sec) 
  throws java.sql.SQLException;
Description

These methods get and set a connection for the interval that the system waits to establish before giving up. This value is an interval in seconds. A value of zero directs the data source to depend on ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required