blob: 90ceb8f64e210fc6b97dca4d19a262916d9324e0 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26package javax.sql;
27
28import java.sql.SQLException;
29import java.io.PrintWriter;
30
31/**
32 * Interface that defines the methods which are common between <code>DataSource</code>,
33 * <code>XADataSource</code> and <code>ConnectionPoolDataSource</code>.
34 *<p>
35 */
36public interface CommonDataSource {
37
38 /**
39 * <p>Retrieves the log writer for this <code>DataSource</code>
40 * object.
41 *
42 * <p>The log writer is a character output stream to which all logging
43 * and tracing messages for this data source will be
44 * printed. This includes messages printed by the methods of this
45 * object, messages printed by methods of other objects manufactured
46 * by this object, and so on. Messages printed to a data source
47 * specific log writer are not printed to the log writer associated
48 * with the <code>java.sql.DriverManager</code> class. When a
49 * <code>DataSource</code> object is
50 * created, the log writer is initially null; in other words, the
51 * default is for logging to be disabled.
52 *
53 * @return the log writer for this data source or null if
54 * logging is disabled
55 * @exception java.sql.SQLException if a database access error occurs
56 * @see #setLogWriter
57 * @since 1.4
58 */
59 java.io.PrintWriter getLogWriter() throws SQLException;
60
61 /**
62 * <p>Sets the log writer for this <code>DataSource</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 data source will be
67 * 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
72 * <code>DataSource</code> object is created the log writer is
73 * initially null; in other words, the default is for logging to be
74 * disabled.
75 *
76 * @param out the new log writer; to disable logging, set to null
77 * @exception SQLException if a database access error occurs
78 * @see #getLogWriter
79 * @since 1.4
80 */
81 void setLogWriter(java.io.PrintWriter out) throws SQLException;
82
83 /**
84 * <p>Sets the maximum time in seconds that this data source will wait
85 * while attempting to connect to a database. A value of zero
86 * specifies that the timeout is the default system timeout
87 * if there is one; otherwise, it specifies that there is no timeout.
88 * When a <code>DataSource</code> object is created, the login timeout is
89 * initially zero.
90 *
91 * @param seconds the data source login time limit
92 * @exception SQLException if a database access error occurs.
93 * @see #getLoginTimeout
94 * @since 1.4
95 */
96 void setLoginTimeout(int seconds) throws SQLException;
97
98 /**
99 * Gets the maximum time in seconds that this data source can wait
100 * while attempting to connect to a database. A value of zero
101 * means that the timeout is the default system timeout
102 * if there is one; otherwise, it means that there is no timeout.
103 * When a <code>DataSource</code> object is created, the login timeout is
104 * initially zero.
105 *
106 * @return the data source login time limit
107 * @exception SQLException if a database access error occurs.
108 * @see #setLoginTimeout
109 * @since 1.4
110 */
111 int getLoginTimeout() throws SQLException;
112
113}