1 | /* |
2 | |
3 | Derby - Class org.apache.derby.jdbc.ClientXADataSource |
4 | |
5 | Copyright (c) 2001, 2005 The Apache Software Foundation or its licensors, where applicable. |
6 | |
7 | Licensed under the Apache License, Version 2.0 (the "License"); |
8 | you may not use this file except in compliance with the License. |
9 | You may obtain a copy of the License at |
10 | |
11 | http://www.apache.org/licenses/LICENSE-2.0 |
12 | |
13 | Unless required by applicable law or agreed to in writing, software |
14 | distributed under the License is distributed on an "AS IS" BASIS, |
15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | See the License for the specific language governing permissions and |
17 | limitations under the License. |
18 | |
19 | */ |
20 | |
21 | package org.apache.derby.jdbc; |
22 | |
23 | import java.sql.SQLException; |
24 | import javax.sql.DataSource; |
25 | import javax.sql.XAConnection; |
26 | import javax.sql.XADataSource; |
27 | |
28 | import org.apache.derby.client.ClientXAConnection; |
29 | import org.apache.derby.client.net.NetLogWriter; |
30 | import org.apache.derby.client.am.SqlException; |
31 | |
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 XADataSource { |
53 | public static final String className__ = "org.apache.derby.jdbc.ClientXADataSource"; |
54 | |
55 | // following serialVersionUID was generated by the JDK's serialver program |
56 | // verify it everytime that ClientXADataSource is modified |
57 | private static final long serialVersionUID = 7057075094707674880L; |
58 | |
59 | public ClientXADataSource() { |
60 | } |
61 | |
62 | public XAConnection getXAConnection() throws SQLException { |
63 | return getXAConnection(getUser(), getPassword()); |
64 | } |
65 | |
66 | public XAConnection getXAConnection(String user, String password) throws SQLException { |
67 | try |
68 | { |
69 | NetLogWriter dncLogWriter = (NetLogWriter) super.computeDncLogWriterForNewConnection("_xads"); |
70 | return new ClientXAConnection(this, dncLogWriter, user, password); |
71 | } |
72 | catch ( SqlException se ) |
73 | { |
74 | throw se.getSQLException(); |
75 | } |
76 | } |
77 | } |