01: /*
02:
03: Derby - Class org.apache.derby.jdbc.ClientXADataSource
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to You under the Apache License, Version 2.0
09: (the "License"); you may not use this file except in compliance with
10: the License. You may obtain a copy of the License at
11:
12: http://www.apache.org/licenses/LICENSE-2.0
13:
14: Unless required by applicable law or agreed to in writing, software
15: distributed under the License is distributed on an "AS IS" BASIS,
16: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: See the License for the specific language governing permissions and
18: limitations under the License.
19:
20: */
21:
22: package org.apache.derby.jdbc;
23:
24: import java.sql.SQLException;
25: import javax.sql.DataSource;
26: import javax.sql.XAConnection;
27: import javax.sql.XADataSource;
28:
29: import org.apache.derby.client.ClientXAConnection;
30: import org.apache.derby.client.net.NetLogWriter;
31: import org.apache.derby.client.am.SqlException;
32:
33: /**
34: * <p>
35: * This is Derby's network XADataSource for use with JDBC3.0 and JDBC2.0.
36: * </p>
37: * An XADataSource is a factory for XAConnection objects. It represents a
38: * RM in a DTP environment. An object that implements the XADataSource
39: * interface is typically registered with a JNDI service provider.
40: * <P>
41: * ClientXADataSource automatically supports the correct JDBC specification version
42: * for the Java Virtual Machine's environment.
43: * <UL>
44: * <LI> JDBC 3.0 - Java 2 - JDK 1.4, J2SE 5.0
45: * <LI> JDBC 2.0 - Java 2 - JDK 1.2,1.3
46: * </UL>
47: *
48: * <P>ClientXADataSource is serializable and referenceable.</p>
49: *
50: * <P>See ClientDataSource for DataSource properties.</p>
51: */
52: public class ClientXADataSource extends ClientDataSource implements
53: XADataSource {
54: public static final String className__ = "org.apache.derby.jdbc.ClientXADataSource";
55:
56: // following serialVersionUID was generated by the JDK's serialver program
57: // verify it everytime that ClientXADataSource is modified
58: private static final long serialVersionUID = 7057075094707674880L;
59:
60: public ClientXADataSource() {
61: }
62:
63: public XAConnection getXAConnection() throws SQLException {
64: return getXAConnection(getUser(), getPassword());
65: }
66:
67: public XAConnection getXAConnection(String user, String password)
68: throws SQLException {
69: try {
70: NetLogWriter dncLogWriter = (NetLogWriter) super
71: .computeDncLogWriterForNewConnection("_xads");
72: return new ClientXAConnection(this , dncLogWriter, user,
73: password);
74: } catch (SqlException se) {
75: throw se.getSQLException();
76: }
77: }
78: }
|