KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jdbc > MetaDataImpl


1  /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * Initial developer(s): Eric HARDESTY
22  * --------------------------------------------------------------------------
23  * $Id: MetaDataImpl.java,v 1.3 2004/03/19 14:31:48 sauthieg Exp $
24  * --------------------------------------------------------------------------
25  */

26 package org.objectweb.jonas.jdbc;
27
28 import java.sql.DatabaseMetaData JavaDoc;
29 import java.sql.SQLException JavaDoc;
30
31 import javax.resource.ResourceException JavaDoc;
32
33 /**
34  * Description of the MetaDataImpl. This is the DatabaseMetadata for
35  * the current JDBC connection.
36  *
37  *@author Eric Hardesty
38  *@created 22 May 2003
39  */

40 public class MetaDataImpl
41        implements javax.resource.spi.ManagedConnectionMetaData JavaDoc {
42
43   private ManagedConnectionImpl mcon;
44   private DatabaseMetaData JavaDoc dMetaData;
45
46   public
47   MetaDataImpl(ManagedConnectionImpl _mcon)
48             throws ResourceException JavaDoc {
49       dMetaData = null;
50       try {
51           mcon = _mcon;
52           dMetaData = mcon.connection.getMetaData();
53       } catch (SQLException JavaDoc se) {
54           throw new ResourceException JavaDoc(se.getMessage());
55       }
56   }
57
58   /** Returns the JDBC Product name
59    *
60    * @return String Product name of the JDBC instance.
61   **/

62   public
63   String JavaDoc getEISProductName() throws ResourceException JavaDoc
64   {
65       try {
66           return(dMetaData.getDatabaseProductName());
67       } catch (SQLException JavaDoc se) {
68           throw new ResourceException JavaDoc(se.getMessage());
69       }
70   }
71
72   /** Returns the JDBC Product version
73    *
74    * @return String Product version of the JDBC instance
75   **/

76   public
77   String JavaDoc getEISProductVersion() throws ResourceException JavaDoc
78   {
79       try {
80           return(dMetaData.getDatabaseProductVersion());
81       } catch (SQLException JavaDoc se) {
82           throw new ResourceException JavaDoc(se.getMessage());
83       }
84   }
85
86   /** Returns maximum limit on number of active concurrent connections
87    * that this JDBC instance can support across client processes.
88    *
89    * @return int of maximum limit for number of active concurrent
90    * connections. 0 is an unlimited number of connections
91   **/

92   public
93   int getMaxConnections() throws ResourceException JavaDoc
94   {
95       try {
96           return(dMetaData.getMaxConnections());
97       } catch (SQLException JavaDoc se) {
98           throw new ResourceException JavaDoc(se.getMessage());
99       }
100   }
101   
102   /** Returns the name of the user associated with the JdbcRaManagedConnection
103    * instance. The name corresponds to the resource principal under
104    * whose security context, a connection to the DB has been
105    * established.
106    *
107    * @return String name of the user
108   **/

109   public
110   String JavaDoc getUserName() throws ResourceException JavaDoc
111   {
112       try {
113           return(dMetaData.getUserName());
114       } catch (SQLException JavaDoc se) {
115           throw new ResourceException JavaDoc(se.getMessage());
116       }
117   }
118 }
119
Popular Tags