/android/upstream/java/sql/Driver.java

https://bitbucket.org/festevezga/xobotos · Java · 125 lines · 11 code · 10 blank · 104 comment · 0 complexity · dd13e6c91925c4e6c526561b90f7feac MD5 · raw file

  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package java.sql;
  18. import java.util.Properties;
  19. /**
  20. * An interface to a JDBC driver.
  21. * <p>
  22. * The JDBC driver uses URLs to specify the location of specific data. URL
  23. * format typically takes the form " {@code xxxx:yyyy:SpecificData}", where "
  24. * {@code xxxx:yyyy}" is referred to as the <i>subprotocol</i> and is normally
  25. * the same for all of a particular driver. " {@code SpecificData}" is a string
  26. * which identifies the particular data source that the driver should use.
  27. * <p>
  28. * A driver needs to be registered with a {@link DriverManager}. It is
  29. * registered and instantiated by calling {@code Class.forName("DriverURL")}
  30. * with the URL string as argument.
  31. *
  32. * @see DriverManager
  33. */
  34. public interface Driver {
  35. /**
  36. * Returns whether the driver thinks that it can open a connection to the
  37. * given URL.
  38. *
  39. * @param url
  40. * the URL to connect to.
  41. * @return {@code true} if the driver thinks that is can open a connection
  42. * to the supplied URL, {@code false} otherwise. Typically, the
  43. * driver will respond {@code true} if it thinks that it can handle
  44. * the subprotocol specified by the driver.
  45. * @throws SQLException
  46. * if a database error occurs.
  47. */
  48. public boolean acceptsURL(String url) throws SQLException;
  49. /**
  50. * Attempts to make a database connection to a data source specified by a
  51. * supplied URL.
  52. *
  53. * @param url
  54. * the URL to connect.
  55. * @param info
  56. * some properties that should be used in establishing the
  57. * connection. The properties consist of name/value pairs of
  58. * strings. Normally, a connection to a database requires at
  59. * least two properties - for {@code "user"} and {@code
  60. * "password"} in order to pass authentication to the database.
  61. * @return the connection to the database.
  62. * @throws SQLException
  63. * if a database error occurs.
  64. */
  65. public Connection connect(String url, Properties info) throws SQLException;
  66. /**
  67. * Gets the driver's major version number.
  68. *
  69. * @return the major version number of the driver - typically starts at 1.
  70. */
  71. public int getMajorVersion();
  72. /**
  73. * Gets the driver's minor version number.
  74. *
  75. * @return the minor version number of the driver - typically starts at 0.
  76. */
  77. public int getMinorVersion();
  78. /**
  79. * Gets information about possible properties for this driver.
  80. * <p>
  81. * This method is intended to provide a listing of possible properties that
  82. * the client of the driver must supply in order to establish a connection
  83. * to a database. Note that the returned array of properties may change
  84. * depending on the supplied list of property values.
  85. *
  86. * @param url
  87. * the URL of the database. An application may call this method
  88. * iteratively as the property list is built up - for example,
  89. * when displaying a dialog to an end-user as part of the
  90. * database login process.
  91. * @param info
  92. * a set of tag/value pairs giving data that a user may be
  93. * prompted to provide in order to connect to the database.
  94. * @return an array of {@code DriverPropertyInfo} records which provide
  95. * details on which additional properties are required (in addition
  96. * to those supplied in the {@code info} parameter) in order to
  97. * connect to the database.
  98. * @throws SQLException
  99. * if a database error occurs.
  100. */
  101. public DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
  102. throws SQLException;
  103. /**
  104. * Reports whether this driver is a genuine JDBC CompliantTM driver. The
  105. * driver may only return {@code true} if it passes all the JDBC compliance
  106. * tests.
  107. * <p>
  108. * A driver may not be fully compliant if the underlying database has
  109. * limited functionality.
  110. *
  111. * @return {@code true} if the driver is fully JDBC compliant, {@code false}
  112. * otherwise.
  113. */
  114. public boolean jdbcCompliant();
  115. }