KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jdbc > oracle > OracleXADataSource


1 /*
2  * XAPool: Open Source XA JDBC Pool
3  * Copyright (C) 2003 Objectweb.org
4  * Initial Developer: Lutris Technologies Inc.
5  * Contact: xapool-public@lists.debian-sf.objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20  * USA
21  */

22 package org.enhydra.jdbc.oracle;
23
24 import org.enhydra.jdbc.standard.StandardXADataSource;
25
26 import javax.sql.XADataSource JavaDoc;
27 import javax.sql.XAConnection JavaDoc;
28 import javax.naming.Reference JavaDoc;
29 import javax.naming.Context JavaDoc;
30 import javax.naming.Name JavaDoc;
31 import java.sql.SQLException JavaDoc;
32 import java.util.Hashtable JavaDoc;
33
34 /**
35  * Data source for creating IdbXAConnections.
36  */

37 public class OracleXADataSource extends StandardXADataSource implements XADataSource {
38
39     /**
40      * Constructor.
41      */

42     public OracleXADataSource () {
43         // Required by JNDI
44
super();
45     }
46
47     /**
48      * Creates an XA connection using the default username and password.
49      */

50     public XAConnection JavaDoc getXAConnection () throws SQLException JavaDoc {
51         return getXAConnection (user, password);
52     }
53
54     /**
55      * Creates an XA connection using the supplied username and password.
56      */

57     public XAConnection JavaDoc getXAConnection (String JavaDoc user, String JavaDoc password) throws SQLException JavaDoc {
58         OracleXAConnection xac = new OracleXAConnection (this, user, password);
59         xac.setTransactionManager(transactionManager);
60         connectionCount++;
61         return xac;
62     }
63
64     /**
65      * The factory interface.
66      */

67     public Object JavaDoc getObjectInstance(Object JavaDoc refObj, Name JavaDoc name, Context JavaDoc nameCtx, Hashtable JavaDoc env) throws Exception JavaDoc {
68         Reference JavaDoc ref = (Reference JavaDoc)refObj;
69         if (ref.getClassName().equals(getClass().getName())) {
70             OracleXADataSource dataSource = new OracleXADataSource ();
71             dataSource.setDriverName((String JavaDoc)ref.get("driverName").getContent());
72             dataSource.setUrl((String JavaDoc)ref.get("url").getContent());
73             return dataSource;
74         } else {
75             return null;
76         }
77     }
78
79 }
80
Popular Tags