src/share/classes/javax/sql/DataSource.java

Print this page




  65  * {@code DataSource} object is retrieved though a lookup operation
  66  * and then used to create a {@code Connection} object.  With a basic
  67  * implementation, the connection obtained through a {@code DataSource}
  68  * object is identical to a connection obtained through the
  69  * {@code DriverManager} facility.
  70  * <p>
  71  * An implementation of {@code DataSource} must include a public no-arg
  72  * constructor.
  73  *
  74  * @since 1.4
  75  */
  76 
  77 public interface DataSource  extends CommonDataSource, Wrapper {
  78 
  79   /**
  80    * <p>Attempts to establish a connection with the data source that
  81    * this {@code DataSource} object represents.
  82    *
  83    * @return  a connection to the data source
  84    * @exception SQLException if a database access error occurs
  85    * @throws SQLTimeoutException  when the driver has determined that the
  86    * timeout value specified by the {@code setLoginTimeout} method
  87    * has been exceeded and has at least tried to cancel the
  88    * current database connection attempt
  89    */
  90   Connection getConnection() throws SQLException;
  91 
  92   /**
  93    * <p>Attempts to establish a connection with the data source that
  94    * this {@code DataSource} object represents.
  95    *
  96    * @param username the database user on whose behalf the connection is
  97    *  being made
  98    * @param password the user's password
  99    * @return  a connection to the data source
 100    * @exception SQLException if a database access error occurs
 101    * @throws SQLTimeoutException  when the driver has determined that the
 102    * timeout value specified by the {@code setLoginTimeout} method
 103    * has been exceeded and has at least tried to cancel the
 104    * current database connection attempt
 105    * @since 1.4
 106    */
 107   Connection getConnection(String username, String password)
 108     throws SQLException;
 109 }


  65  * {@code DataSource} object is retrieved though a lookup operation
  66  * and then used to create a {@code Connection} object.  With a basic
  67  * implementation, the connection obtained through a {@code DataSource}
  68  * object is identical to a connection obtained through the
  69  * {@code DriverManager} facility.
  70  * <p>
  71  * An implementation of {@code DataSource} must include a public no-arg
  72  * constructor.
  73  *
  74  * @since 1.4
  75  */
  76 
  77 public interface DataSource  extends CommonDataSource, Wrapper {
  78 
  79   /**
  80    * <p>Attempts to establish a connection with the data source that
  81    * this {@code DataSource} object represents.
  82    *
  83    * @return  a connection to the data source
  84    * @exception SQLException if a database access error occurs
  85    * @throws java.sql.SQLTimeoutException  when the driver has determined that the
  86    * timeout value specified by the {@code setLoginTimeout} method
  87    * has been exceeded and has at least tried to cancel the
  88    * current database connection attempt
  89    */
  90   Connection getConnection() throws SQLException;
  91 
  92   /**
  93    * <p>Attempts to establish a connection with the data source that
  94    * this {@code DataSource} object represents.
  95    *
  96    * @param username the database user on whose behalf the connection is
  97    *  being made
  98    * @param password the user's password
  99    * @return  a connection to the data source
 100    * @exception SQLException if a database access error occurs
 101    * @throws java.sql.SQLTimeoutException  when the driver has determined that the
 102    * timeout value specified by the {@code setLoginTimeout} method
 103    * has been exceeded and has at least tried to cancel the
 104    * current database connection attempt
 105    * @since 1.4
 106    */
 107   Connection getConnection(String username, String password)
 108     throws SQLException;
 109 }