001/* Driver.java -- A JDBC driver
002   Copyright (C) 1999, 2000, 2006 Free Software Foundation, Inc.
003
004This file is part of GNU Classpath.
005
006GNU Classpath is free software; you can redistribute it and/or modify
007it under the terms of the GNU General Public License as published by
008the Free Software Foundation; either version 2, or (at your option)
009any later version.
010 
011GNU Classpath is distributed in the hope that it will be useful, but
012WITHOUT ANY WARRANTY; without even the implied warranty of
013MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014General Public License for more details.
015
016You should have received a copy of the GNU General Public License
017along with GNU Classpath; see the file COPYING.  If not, write to the
018Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
01902110-1301 USA.
020
021Linking this library statically or dynamically with other modules is
022making a combined work based on this library.  Thus, the terms and
023conditions of the GNU General Public License cover the whole
024combination.
025
026As a special exception, the copyright holders of this library give you
027permission to link this library with independent modules to produce an
028executable, regardless of the license terms of these independent
029modules, and to copy and distribute the resulting executable under
030terms of your choice, provided that you also meet, for each linked
031independent module, the terms and conditions of the license of that
032module.  An independent module is a module which is not derived from
033or based on this library.  If you modify this library, you may extend
034this exception to your version of the library, but you are not
035obligated to do so.  If you do not wish to do so, delete this
036exception statement from your version. */
037
038package java.sql;
039
040import java.util.Properties;
041
042/**
043  * This interface specifies a mechanism for accessing a JDBC database
044  * driver.  When the class implementing this method is loaded, it should
045  * register an instance of itself with the <code>DriverManager</code> in
046  * a static initializer.  
047  * <p>
048  * Because the <code>DriverManager</code> might attempt to use several
049  * drivers to find one that can connect to the requested database, 
050  * this driver should not cause large numbers of classes and code to
051  * be loaded.  If another driver is the one that ends up performing the
052  * request, any loading done by this driver would be wasted.
053  *
054  * @author Aaron M. Renn (arenn@urbanophile.com)
055  */
056public interface Driver 
057{
058  /**
059   * This method connects to the specified database using the connection
060   * properties supplied.  If the driver does not understand the database
061   * URL, it should return <code>null</code> instead of throwing an
062   * exception since the <code>DriverManager</code> will probe a driver
063   * in this manner.
064   * 
065   * @param url The URL string for this connection.
066   * @param properties The list of database connection properties.
067   * @return A <code>Connection</code> object for the newly established
068   *         connection, or <code>null</code> if the URL is not understood.
069   * @exception SQLException If an error occurs.
070   */
071  Connection connect(String url, Properties properties) throws SQLException;
072
073  /**
074   * This method tests whether or not the driver believes it can connect to
075   * the specified database.  The driver should only test whether it 
076   * understands and accepts the URL. It should not necessarily attempt to 
077   * probe the database for a connection.
078   *
079   * @param url The database URL string.
080   * @return <code>true</code> if the drivers can connect to the database, 
081   *         <code>false</code> otherwise.
082   * @exception SQLException If an error occurs.
083   */
084  boolean acceptsURL(String url) throws SQLException;
085
086  /**
087   * This method returns an array of possible properties that could be
088   * used to connect to the specified database.
089   *
090   * @param url The URL string of the database to connect to.
091   * @param properties The list of properties the caller is planning to use
092   *        to connect to the database.
093   * @return A list of possible additional properties for a connection to this
094   *         database.  This list may be empty.
095   * @exception SQLException If an error occurs.
096   */
097  DriverPropertyInfo[] getPropertyInfo(String url, Properties properties)
098    throws SQLException;
099
100  /**
101   * This method returns the major version number of the driver.
102   *
103   * @return The major version number of the driver.
104   */      
105  int getMajorVersion();
106
107  /**
108   * This method returns the minor version number of the driver.
109   *
110   * @return The minor version number of the driver.
111   */
112  int getMinorVersion();
113
114  /**
115   * This method tests whether or not the driver is JDBC compliant.  This
116   * method should only return <code>true</code> if the driver has been
117   * certified as JDBC compliant.
118   *
119   * @return <code>true</code> if the driver has been certified JDBC compliant,
120   *         <code>false</code> otherwise.
121   */
122  boolean jdbcCompliant();
123}