1. /*
  2. * @(#)XADataSource.java 1.9 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.*;
  9. /**
  10. * A factory for <code>XAConnection</code> objects that is used internally.
  11. * An object that implements the <code>XADataSource</code> interface is
  12. * typically registered with a naming service that uses the
  13. * Java Naming and Directory Interface<sup><font size=-3>TM</font></sup>
  14. * (JNDI).
  15. *
  16. * @since 1.4
  17. */
  18. public interface XADataSource {
  19. /**
  20. * Attempts to establish a physical database connection that can be
  21. * used in a distributed transaction.
  22. *
  23. * @return an <code>XAConnection</code> object, which represents a
  24. * physical connection to a data source, that can be used in
  25. * a distributed transaction
  26. * @exception SQLException if a database access error occurs
  27. */
  28. XAConnection getXAConnection() throws SQLException;
  29. /**
  30. * Attempts to establish a physical database connection, using the given
  31. * user name and password. The connection that is returned is one that
  32. * can be used in a distributed transaction.
  33. *
  34. * @param user the database user on whose behalf the connection is being made
  35. * @param password the user's password
  36. * @return an <code>XAConnection</code> object, which represents a
  37. * physical connection to a data source, that can be used in
  38. * a distributed transaction
  39. * @exception SQLException if a database access error occurs
  40. */
  41. XAConnection getXAConnection(String user, String password)
  42. throws SQLException;
  43. /**
  44. * <p>Retrieves the log writer for this <code>XADataSource</code> object.
  45. *
  46. * @return the log writer for this data source; <code>null</code> if no log
  47. * writer has been set, which means that logging is disabled
  48. * @exception SQLException if a database access error occurs
  49. * @see #setLogWriter
  50. */
  51. java.io.PrintWriter getLogWriter() throws SQLException;
  52. /**
  53. * Sets the log writer for this <code>XADataSource</code> object
  54. * to the given <code>java.io.PrintWriter</code> object.
  55. * <P>
  56. * The log writer is a character output stream to which all logging
  57. * and tracing messages for this <code>XADataSource</code> object will be
  58. * printed. This includes messages printed by the methods of this
  59. * object, messages printed by methods of other objects manufactured
  60. * by this object, and so on. Messages printed to a log writer that is
  61. * specific to a data source are not printed to the log writer associated
  62. * with the <code>java.sql.DriverManager</code> class. When a data source
  63. * object is created, the log writer is initially <code>null</code>.
  64. *
  65. * @param out the new log writer; to disable logging, set to <code>null</code>
  66. * @exception SQLException if a database access error occurs
  67. * @see #getLogWriter
  68. */
  69. void setLogWriter(java.io.PrintWriter out) throws SQLException;
  70. /**
  71. * <p>Sets the maximum time in seconds that this data source will wait
  72. * while attempting to connect to a data source. A value of zero
  73. * specifies that the timeout is the default system timeout
  74. * if there is one; otherwise, it specifies that there is no timeout.
  75. * When a data source object is created, the login timeout is
  76. * initially zero.
  77. *
  78. * @param seconds the data source login time limit
  79. * @exception SQLException if a database access error occurs
  80. * @see #getLoginTimeout
  81. */
  82. void setLoginTimeout(int seconds) throws SQLException;
  83. /**
  84. * Retrieves the maximum time in seconds that this data source can wait
  85. * while attempting to connect to a data source. A value of zero
  86. * means that the timeout is the default system timeout
  87. * if there is one; otherwise, it means that there is no timeout.
  88. * When a data source object is created, the login timeout is
  89. * initially zero.
  90. *
  91. * @return the number of seconds that is the login time limit for this
  92. * <code>XADataSource</code> object or zero if there is no
  93. * no timeout limit or the timeout limit is the default system
  94. * timeout limit if there is one
  95. * @exception SQLException if a database access error occurs
  96. * @see #setLoginTimeout
  97. */
  98. int getLoginTimeout() throws SQLException;
  99. }