Path: blob/master/src/java.sql/share/classes/javax/sql/XADataSource.java
41152 views
/*1* Copyright (c) 2000, 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.*;2829/**30* A factory for {@code XAConnection} objects that is used internally.31* An object that implements the {@code XADataSource} interface is32* typically registered with a naming service that uses the33* Java Naming and Directory Interface34* (JNDI).35* <p>36* An implementation of {@code XADataSource} must include a public no-arg37* constructor.38* @since 1.439*/4041public interface XADataSource extends CommonDataSource {4243/**44* Attempts to establish a physical database connection that can be45* used in a distributed transaction.46*47* @return an {@code XAConnection} object, which represents a48* physical connection to a data source, that can be used in49* a distributed transaction50* @throws SQLException if a database access error occurs51* @throws SQLFeatureNotSupportedException if the JDBC driver does not support52* this method53* @throws SQLTimeoutException when the driver has determined that the54* timeout value specified by the {@code setLoginTimeout} method55* has been exceeded and has at least tried to cancel the56* current database connection attempt57* @since 1.458*/59XAConnection getXAConnection() throws SQLException;6061/**62* Attempts to establish a physical database connection, using the given63* user name and password. The connection that is returned is one that64* can be used in a distributed transaction.65*66* @param user the database user on whose behalf the connection is being made67* @param password the user's password68* @return an {@code XAConnection} object, which represents a69* physical connection to a data source, that can be used in70* a distributed transaction71* @throws SQLException if a database access error occurs72* @throws SQLFeatureNotSupportedException if the JDBC driver does not support73* this method74* @throws SQLTimeoutException when the driver has determined that the75* timeout value specified by the {@code setLoginTimeout} method76* has been exceeded and has at least tried to cancel the77* current database connection attempt78* @since 1.479*/80XAConnection getXAConnection(String user, String password)81throws SQLException;8283/**84* {@inheritDoc}85* @since 1.486*/87@Override88java.io.PrintWriter getLogWriter() throws SQLException;8990/**91* {@inheritDoc}92* @since 1.493*/94@Override95void setLogWriter(java.io.PrintWriter out) throws SQLException;9697/**98* {@inheritDoc}99* @since 1.4100*/101@Override102void setLoginTimeout(int seconds) throws SQLException;103104/**105* {@inheritDoc}106* @since 1.4107*/108@Override109int getLoginTimeout() throws SQLException;110111// JDBC 4.3112113/**114* Creates a new {@code XAConnectionBuilder} instance115* @implSpec116* The default implementation will throw a {@code SQLFeatureNotSupportedException}.117* @return The XAConnectionBuilder instance that was created118* @throws SQLException if an error occurs creating the builder119* @throws SQLFeatureNotSupportedException if the driver does not support sharding120* @since 9121* @see XAConnectionBuilder122*/123default XAConnectionBuilder createXAConnectionBuilder() throws SQLException {124throw new SQLFeatureNotSupportedException("createXAConnectionBuilder not implemented");125};126127}128129130