KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > jdbc > ClientXADataSource


1 /*
2
3    Derby - Class org.apache.derby.jdbc.ClientXADataSource
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to You under the Apache License, Version 2.0
9    (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 JavaDoc;
25 import javax.sql.DataSource JavaDoc;
26 import javax.sql.XAConnection JavaDoc;
27 import javax.sql.XADataSource JavaDoc;
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 /**
35  * <p>
36  * This is Derby's network XADataSource for use with JDBC3.0 and JDBC2.0.
37  * </p>
38  * An XADataSource is a factory for XAConnection objects. It represents a
39  * RM in a DTP environment. An object that implements the XADataSource
40  * interface is typically registered with a JNDI service provider.
41  * <P>
42  * ClientXADataSource automatically supports the correct JDBC specification version
43  * for the Java Virtual Machine's environment.
44  * <UL>
45  * <LI> JDBC 3.0 - Java 2 - JDK 1.4, J2SE 5.0
46  * <LI> JDBC 2.0 - Java 2 - JDK 1.2,1.3
47  * </UL>
48  *
49  * <P>ClientXADataSource is serializable and referenceable.</p>
50  *
51  * <P>See ClientDataSource for DataSource properties.</p>
52  */

53 public class ClientXADataSource extends ClientDataSource implements XADataSource JavaDoc {
54     public static final String JavaDoc 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 JavaDoc getXAConnection() throws SQLException JavaDoc {
64         return getXAConnection(getUser(), getPassword());
65     }
66
67     public XAConnection JavaDoc getXAConnection(String JavaDoc user, String JavaDoc password) throws SQLException JavaDoc {
68         try
69         {
70             NetLogWriter dncLogWriter = (NetLogWriter) super.computeDncLogWriterForNewConnection("_xads");
71             return new ClientXAConnection(this, dncLogWriter, user, password);
72         }
73         catch ( SqlException se )
74         {
75             throw se.getSQLException();
76         }
77     }
78 }
79
Popular Tags