1. /*
  2. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  3. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  4. */
  5. package javax.sql;
  6. import java.sql.*;
  7. /**
  8. * A factory for XAConnection objects. An object that implements the
  9. * XADataSource interface is typically registered with a JNDI service
  10. * provider.
  11. */
  12. public interface XADataSource {
  13. /**
  14. * <p>Attempt to establish a database connection.
  15. *
  16. * @return a Connection to the database
  17. * @exception SQLException if a database-access error occurs.
  18. */
  19. XAConnection getXAConnection() throws SQLException;
  20. /**
  21. * <p>Attempt to establish a database connection.
  22. *
  23. * @param user the database user on whose behalf the Connection is being made
  24. * @param password the user's password
  25. * @return a Connection to the database
  26. * @exception SQLException if a database-access error occurs.
  27. */
  28. XAConnection getXAConnection(String user, String password)
  29. throws SQLException;
  30. /**
  31. * <p>Get the log writer for this data source.
  32. *
  33. * <p>The log writer is a character output stream to which all logging
  34. * and tracing messages for this data source object instance will be
  35. * printed. This includes messages printed by the methods of this
  36. * object, messages printed by methods of other objects manufactured
  37. * by this object, and so on. Messages printed to a data source
  38. * specific log writer are not printed to the log writer associated
  39. * with the java.sql.Drivermanager class. When a data source object is
  40. * created the log writer is initially null, in other words, logging
  41. * is disabled.
  42. *
  43. * @return the log writer for this data source, null if disabled
  44. * @exception SQLException if a database-access error occurs.
  45. */
  46. java.io.PrintWriter getLogWriter() throws SQLException;
  47. /**
  48. * <p>Set the log writer for this data source.
  49. *
  50. * <p>The log writer is a character output stream to which all logging
  51. * and tracing messages for this data source object instance will be
  52. * printed. This includes messages printed by the methods of this
  53. * object, messages printed by methods of other objects manufactured
  54. * by this object, and so on. Messages printed to a data source
  55. * specific log writer are not printed to the log writer associated
  56. * with the java.sql.Drivermanager class. When a data source object is
  57. * created the log writer is initially null, in other words, logging
  58. * is disabled.
  59. *
  60. * @param out the new log writer; to disable, set to null
  61. * @exception SQLException if a database-access error occurs.
  62. */
  63. void setLogWriter(java.io.PrintWriter out) throws SQLException;
  64. /**
  65. * <p>Sets the maximum time in seconds that this data source will wait
  66. * while attempting to connect to a database. A value of zero
  67. * specifies that the timeout is the default system timeout
  68. * if there is one; otherwise it specifies that there is no timeout.
  69. * When a data source object is created the login timeout is
  70. * initially zero.
  71. *
  72. * @param seconds the data source login time limit
  73. * @exception SQLException if a database access error occurs.
  74. */
  75. void setLoginTimeout(int seconds) throws SQLException;
  76. /**
  77. * Gets the maximum time in seconds that this data source can wait
  78. * while attempting to connect to a database. A value of zero
  79. * means that the timeout is the default system timeout
  80. * if there is one; otherwise it means that there is no timeout.
  81. * When a data source object is created the login timeout is
  82. * initially zero.
  83. *
  84. * @return the data source login time limit
  85. * @exception SQLException if a database access error occurs.
  86. */
  87. int getLoginTimeout() throws SQLException;
  88. }