KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derbyTesting > junit > JDBCClient


1 /*
2  *
3  * Derby - Class JDBCClient
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,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17  * either express or implied. See the License for the specific
18  * language governing permissions and limitations under the License.
19  */

20 package org.apache.derbyTesting.junit;
21
22 /**
23  * Type-safe enumerator of valid JDBC clients.
24  * Each JDBC client definition consists of the client name, the name of the
25  * JDBC driver class, the name of a DataSource class and the base JDBC url.
26  */

27 public final class JDBCClient {
28
29     /**
30      * The embedded JDBC client.
31      */

32     static final JDBCClient EMBEDDED = new JDBCClient(
33             "Embedded",
34             "org.apache.derby.jdbc.EmbeddedDriver",
35             "org.apache.derby.jdbc.EmbeddedDataSource",
36             "jdbc:derby:");
37     
38     /**
39      * The Derby network client.
40      */

41     static final JDBCClient DERBYNETCLIENT= new JDBCClient(
42             "DerbyNetClient",
43             "org.apache.derby.jdbc.ClientDriver",
44             "org.apache.derby.jdbc.ClientDataSource",
45             "jdbc:derby://");
46     
47     /**
48      * The DB2 Universal JDBC network client.
49      * AKA: JCC or DerbyNet.
50      * (the "old net" client for Derby).
51      */

52     static final JDBCClient DB2CLIENT= new JDBCClient(
53             "DerbyNet",
54             "com.ibm.db2.jcc.DB2Driver",
55             null,
56             "jdbc:derby:net://");
57     
58     /**
59      * Is this the embdded client.
60     */

61     public boolean isEmbedded()
62     {
63         return getName().equals(EMBEDDED.getName());
64     }
65     /**
66      * Is this Derby's network client.
67      * @return
68      */

69     public boolean isDerbyNetClient()
70     {
71         return getName().equals(DERBYNETCLIENT.getName());
72     }
73     /**
74      * Is this DB2's Universal JDBC
75      * @return
76      */

77     public boolean isDB2Client()
78     {
79         return getName().equals(DB2CLIENT.getName());
80     }
81     
82     /**
83      * Get the name of the client
84      */

85     public String JavaDoc getName()
86     {
87         return frameWork;
88     }
89     
90     /**
91      * Get JDBC driver class name.
92      *
93      * @return class name for JDBC driver.
94      */

95     public String JavaDoc getJDBCDriverName() {
96         return driverClassName;
97     }
98
99     /**
100      * Get DataSource class name.
101      *
102      * @return class name for DataSource implementation.
103      */

104     public String JavaDoc getDataSourceClassName() {
105         return dsClassName;
106     }
107
108     /**
109      * Return the base JDBC url.
110      * The JDBC base url specifies the protocol and possibly the subprotcol
111      * in the JDBC connection string.
112      *
113      * @return JDBC base url.
114      */

115     public String JavaDoc getUrlBase() {
116         return urlBase;
117     }
118     
119     /**
120      * Return string representation of this object.
121      *
122      * @return string representation of this object.
123      */

124     public String JavaDoc toString() {
125         return frameWork;
126     }
127     
128     /**
129      * Create a JDBC client definition.
130      */

131     private JDBCClient(String JavaDoc frameWork, String JavaDoc driverClassName,
132                        String JavaDoc dataSourceClassName, String JavaDoc urlBase) {
133         this.frameWork = frameWork;
134         this.driverClassName = driverClassName;
135         this.dsClassName = dataSourceClassName;
136         this.urlBase = urlBase;
137     }
138     
139     private final String JavaDoc frameWork;
140     private final String JavaDoc driverClassName;
141     private final String JavaDoc dsClassName;
142     private final String JavaDoc urlBase;
143     
144 }
145
Popular Tags