Path: blob/master/src/java.sql/share/classes/javax/sql/CommonDataSource.java
41152 views
/*1* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.sql;2627import java.sql.SQLException;28import java.sql.SQLFeatureNotSupportedException;29import java.sql.ShardingKeyBuilder;30import java.util.logging.Logger;3132/**33* Interface that defines the methods which are common between {@code DataSource},34* {@code XADataSource} and {@code ConnectionPoolDataSource}.35*36* @since 1.637*/38public interface CommonDataSource {3940/**41* <p>Retrieves the log writer for this {@code DataSource}42* object.43*44* <p>The log writer is a character output stream to which all logging45* and tracing messages for this data source will be46* printed. This includes messages printed by the methods of this47* object, messages printed by methods of other objects manufactured48* by this object, and so on. Messages printed to a data source49* specific log writer are not printed to the log writer associated50* with the {@code java.sql.DriverManager} class. When a51* {@code DataSource} object is52* created, the log writer is initially null; in other words, the53* default is for logging to be disabled.54*55* @return the log writer for this data source or null if56* logging is disabled57* @throws java.sql.SQLException if a database access error occurs58* @see #setLogWriter59*/60java.io.PrintWriter getLogWriter() throws SQLException;6162/**63* <p>Sets the log writer for this {@code DataSource}64* object to the given {@code java.io.PrintWriter} object.65*66* <p>The log writer is a character output stream to which all logging67* and tracing messages for this data source will be68* printed. This includes messages printed by the methods of this69* object, messages printed by methods of other objects manufactured70* by this object, and so on. Messages printed to a data source-71* specific log writer are not printed to the log writer associated72* with the {@code java.sql.DriverManager} class. When a73* {@code DataSource} object is created the log writer is74* initially null; in other words, the default is for logging to be75* disabled.76*77* @param out the new log writer; to disable logging, set to null78* @throws SQLException if a database access error occurs79* @see #getLogWriter80*/81void setLogWriter(java.io.PrintWriter out) throws SQLException;8283/**84* <p>Sets the maximum time in seconds that this data source will wait85* while attempting to connect to a database. A value of zero86* specifies that the timeout is the default system timeout87* if there is one; otherwise, it specifies that there is no timeout.88* When a {@code DataSource} object is created, the login timeout is89* initially zero.90*91* @param seconds the data source login time limit92* @throws SQLException if a database access error occurs.93* @see #getLoginTimeout94*/95void setLoginTimeout(int seconds) throws SQLException;9697/**98* Gets the maximum time in seconds that this data source can wait99* while attempting to connect to a database. A value of zero100* means that the timeout is the default system timeout101* if there is one; otherwise, it means that there is no timeout.102* When a {@code DataSource} object is created, the login timeout is103* initially zero.104*105* @return the data source login time limit106* @throws SQLException if a database access error occurs.107* @see #setLoginTimeout108*/109int getLoginTimeout() throws SQLException;110111//------------------------- JDBC 4.1 -----------------------------------112113/**114* Return the parent Logger of all the Loggers used by this data source. This115* should be the Logger farthest from the root Logger that is116* still an ancestor of all of the Loggers used by this data source. Configuring117* this Logger will affect all of the log messages generated by the data source.118* In the worst case, this may be the root Logger.119*120* @return the parent Logger for this data source121* @throws SQLFeatureNotSupportedException if the data source does not use122* {@code java.util.logging}123* @since 1.7124*/125public Logger getParentLogger() throws SQLFeatureNotSupportedException;126127//------------------------- JDBC 4.3 -----------------------------------128129/**130* Creates a new {@code ShardingKeyBuilder} instance131* @implSpec132* The default implementation will throw a {@code SQLFeatureNotSupportedException}.133* @return The ShardingKeyBuilder instance that was created134* @throws SQLException if an error occurs creating the builder135* @throws SQLFeatureNotSupportedException if the driver does not support this method136* @since 9137* @see ShardingKeyBuilder138*/139default ShardingKeyBuilder createShardingKeyBuilder() throws SQLException {140throw new SQLFeatureNotSupportedException("createShardingKeyBuilder not implemented");141};142}143144145