1. /*
  2. * @(#)ConnectionPoolDataSource.java 1.10 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.sql;
  8. import java.sql.SQLException;
  9. /**
  10. * A factory for <code>PooledConnection</code>
  11. * objects. An object that implements this interface will typically be
  12. * registered with a naming service that is based on the
  13. * Java<sup><font size=-2>TM</font></sup> Naming and Directory Interface
  14. * (JNDI).
  15. *
  16. * @since 1.4
  17. */
  18. public interface ConnectionPoolDataSource {
  19. /**
  20. * Attempts to establish a physical database connection that can
  21. * be used as a pooled connection.
  22. *
  23. * @return a <code>PooledConnection</code> object that is a physical
  24. * connection to the database that this
  25. * <code>ConnectionPoolDataSource</code> object represents
  26. * @exception SQLException if a database access error occurs
  27. */
  28. PooledConnection getPooledConnection() throws SQLException;
  29. /**
  30. * Attempts to establish a physical database connection that can
  31. * be used as a pooled connection.
  32. *
  33. * @param user the database user on whose behalf the connection is being made
  34. * @param password the user's password
  35. * @return a <code>PooledConnection</code> object that is a physical
  36. * connection to the database that this
  37. * <code>ConnectionPoolDataSource</code> object represents
  38. * @exception SQLException if a database access error occurs
  39. */
  40. PooledConnection getPooledConnection(String user, String password)
  41. throws SQLException;
  42. /**
  43. * Retrieves the log writer for this <code>ConnectionPoolDataSource</code>
  44. * object.
  45. * <p>The log writer is a character output stream to which all logging
  46. * and tracing messages for this <code>ConnectionPoolDataSource</code> object
  47. * are printed. This includes messages printed by the methods of this
  48. * object, messages printed by methods of other objects manufactured
  49. * by this object, and so on. Messages printed to a data source-
  50. * specific log writer are not printed to the log writer associated
  51. * with the <code>java.sql.DriverManager</code> class. When a data
  52. * source object is created, the log writer is initially null; in other
  53. * words, the default is for logging to be disabled.
  54. *
  55. * @return the log writer for this <code>ConnectionPoolDataSource</code>
  56. * object or <code>null</code> if logging is disabled
  57. * @exception SQLException if a database access error occurs
  58. * @see #setLogWriter
  59. */
  60. java.io.PrintWriter getLogWriter() throws SQLException;
  61. /**
  62. * Sets the log writer for this <code>ConnectionPoolDataSource</code>
  63. * object to the given <code>java.io.PrintWriter</code> object.
  64. *
  65. * <p>The log writer is a character output stream to which all logging
  66. * and tracing messages for this <code>ConnectionPoolDataSource</code>
  67. * object are printed. This includes messages printed by the methods of this
  68. * object, messages printed by methods of other objects manufactured
  69. * by this object, and so on. Messages printed to a data source-
  70. * specific log writer are not printed to the log writer associated
  71. * with the <code>java.sql.Drivermanager</code> class. When a data
  72. * source object is created, the log writer is initially null; in other
  73. * words, the default is for logging to be disabled.
  74. *
  75. * @param out the new log writer; <code>null</code> to disable logging
  76. * @exception SQLException if a database access error occurs
  77. * @see #getLogWriter
  78. */
  79. void setLogWriter(java.io.PrintWriter out) throws SQLException;
  80. /**
  81. * Sets the maximum time in seconds that this
  82. * <code>ConnectionPoolDataSource</code> object will wait
  83. * while attempting to connect to a database. A value of zero
  84. * specifies that the timeout is the default system timeout
  85. * if there is one; otherwise, it specifies that there is no timeout.
  86. * When a <code>ConnectionPoolDataSource</code> object is created,
  87. * the login timeout is initially zero.
  88. *
  89. * @param seconds the data source login time limit
  90. * @exception SQLException if a database access error occurs.
  91. * @see #getLoginTimeout
  92. */
  93. void setLoginTimeout(int seconds) throws SQLException;
  94. /**
  95. * Retrieves the maximum time in seconds that this
  96. * <code>ConnectionPoolDataSource</code> object will wait
  97. * while attempting to connect to a database. A value of zero
  98. * means that the timeout is the default system timeout
  99. * if there is one; otherwise, it means that there is no timeout.
  100. * When a <code>DataSource</code> object is created, its login timeout is
  101. * initially zero.
  102. *
  103. * @return the data source login time limit
  104. * @exception SQLException if a database access error occurs.
  105. * @see #setLoginTimeout
  106. */
  107. int getLoginTimeout() throws SQLException;
  108. }