home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / main.bin / Driver.java < prev    next >
Text File  |  1997-05-20  |  6KB  |  138 lines

  1. /*
  2.  * @(#)Driver.java    1.5 97/02/11
  3.  * 
  4.  * Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  * CopyrightVersion 1.1_beta
  20.  * 
  21.  */
  22.  
  23. package java.sql;
  24.  
  25. /**
  26.  * <P>The Java SQL framework allows for multiple database drivers.
  27.  *
  28.  * <P>Each driver should supply a class that implements
  29.  * the Driver interface.
  30.  *
  31.  * <P>The DriverManager will try to load as many drivers as it can
  32.  * find and then for any given connection request, it will ask each
  33.  * driver in turn to try to connect to the target URL.
  34.  *
  35.  * <P>It is strongly recommended that each Driver class should be
  36.  * small and standalone so that the Driver class can be loaded and
  37.  * queried without bringing in vast quantities of supporting code.
  38.  *
  39.  * <P>When a Driver class is loaded, it should create an instance of
  40.  * itself and register it with the DriverManager. This means that a
  41.  * user can load and register a driver by doing
  42.  * Class.forName("foo.bah.Driver").
  43.  *
  44.  * @see DriverManager
  45.  * @see Connection 
  46.  */
  47. public interface Driver {
  48.  
  49.     /**
  50.      * Try to make a database connection to the given URL.
  51.      * The driver should return "null" if it realizes it is the wrong kind
  52.      * of driver to connect to the given URL.  This will be common, as when
  53.      * the JDBC driver manager is asked to connect to a given URL it passes
  54.      * the URL to each loaded driver in turn.
  55.      *
  56.      * <P>The driver should raise a SQLException if it is the right 
  57.      * driver to connect to the given URL, but has trouble connecting to
  58.      * the database.
  59.      *
  60.      * <P>The java.util.Properties argument can be used to passed arbitrary
  61.      * string tag/value pairs as connection arguments.
  62.      * Normally at least "user" and "password" properties should be
  63.      * included in the Properties.
  64.      *
  65.      * @param url The URL of the database to connect to
  66.      * @param info a list of arbitrary string tag/value pairs as
  67.      * connection arguments; normally at least a "user" and
  68.      * "password" property should be included
  69.      * @return a Connection to the URL
  70.      * @exception SQLException if a database-access error occurs.
  71.      */
  72.     Connection connect(String url, java.util.Properties info)
  73.         throws SQLException;
  74.  
  75.     /**
  76.      * Returns true if the driver thinks that it can open a connection
  77.      * to the given URL.  Typically drivers will return true if they
  78.      * understand the subprotocol specified in the URL and false if
  79.      * they don't.
  80.      *
  81.      * @param url The URL of the database.
  82.      * @return True if this driver can connect to the given URL.  
  83.      * @exception SQLException if a database-access error occurs.
  84.      */
  85.     boolean acceptsURL(String url) throws SQLException;
  86.  
  87.  
  88.     /**
  89.      * <p>The getPropertyInfo method is intended to allow a generic GUI tool to 
  90.      * discover what properties it should prompt a human for in order to get 
  91.      * enough information to connect to a database.  Note that depending on
  92.      * the values the human has supplied so far, additional values may become
  93.      * necessary, so it may be necessary to iterate though several calls
  94.      * to getPropertyInfo.
  95.      *
  96.      * @param url The URL of the database to connect to.
  97.      * @param info A proposed list of tag/value pairs that will be sent on
  98.      *          connect open.
  99.      * @return An array of DriverPropertyInfo objects describing possible
  100.      *          properties.  This array may be an empty array if no properties
  101.      *          are required.
  102.      * @exception SQLException if a database-access error occurs.
  103.      */
  104.     DriverPropertyInfo[] getPropertyInfo(String url, java.util.Properties info)
  105.              throws SQLException;
  106.  
  107.  
  108.     /**
  109.      * Get the driver's major version number. Initially this should be 1.
  110.      */
  111.     int getMajorVersion();
  112.  
  113.     /**
  114.      * Get the driver's minor version number. Initially this should be 0.
  115.      */
  116.     int getMinorVersion();
  117.  
  118.  
  119.     /**
  120.      * Report whether the Driver is a genuine JDBC COMPLIANT (tm) driver.
  121.      * A driver may only report "true" here if it passes the JDBC compliance
  122.      * tests, otherwise it is required to return false.
  123.      *
  124.      * JDBC compliance requires full support for the JDBC API and full support
  125.      * for SQL 92 Entry Level.  It is expected that JDBC compliant drivers will
  126.      * be available for all the major commercial databases.
  127.      *
  128.      * This method is not intended to encourage the development of non-JDBC
  129.      * compliant drivers, but is a recognition of the fact that some vendors
  130.      * are interested in using the JDBC API and framework for lightweight
  131.      * databases that do not support full database functionality, or for
  132.      * special databases such as document information retrieval where a SQL
  133.      * implementation may not be feasible.
  134.      */
  135.     boolean jdbcCompliant();
  136.  
  137.