001: /*
002: *
003: * Derby - Class JDBCClient
004: *
005: * Licensed to the Apache Software Foundation (ASF) under one or more
006: * contributor license agreements. See the NOTICE file distributed with
007: * this work for additional information regarding copyright ownership.
008: * The ASF licenses this file to You under the Apache License, Version 2.0
009: * (the "License"); you may not use this file except in compliance with
010: * the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
017: * either express or implied. See the License for the specific
018: * language governing permissions and limitations under the License.
019: */
020: package org.apache.derbyTesting.junit;
021:
022: /**
023: * Type-safe enumerator of valid JDBC clients.
024: * Each JDBC client definition consists of the client name, the name of the
025: * JDBC driver class, the name of a DataSource class and the base JDBC url.
026: */
027: public final class JDBCClient {
028:
029: /**
030: * The embedded JDBC client.
031: */
032: static final JDBCClient EMBEDDED = new JDBCClient("Embedded",
033: "org.apache.derby.jdbc.EmbeddedDriver",
034: "org.apache.derby.jdbc.EmbeddedDataSource", "jdbc:derby:");
035:
036: /**
037: * The Derby network client.
038: */
039: static final JDBCClient DERBYNETCLIENT = new JDBCClient(
040: "DerbyNetClient", "org.apache.derby.jdbc.ClientDriver",
041: "org.apache.derby.jdbc.ClientDataSource", "jdbc:derby://");
042:
043: /**
044: * The DB2 Universal JDBC network client.
045: * AKA: JCC or DerbyNet.
046: * (the "old net" client for Derby).
047: */
048: static final JDBCClient DB2CLIENT = new JDBCClient("DerbyNet",
049: "com.ibm.db2.jcc.DB2Driver", null, "jdbc:derby:net://");
050:
051: /**
052: * Is this the embdded client.
053: */
054: public boolean isEmbedded() {
055: return getName().equals(EMBEDDED.getName());
056: }
057:
058: /**
059: * Is this Derby's network client.
060: * @return
061: */
062: public boolean isDerbyNetClient() {
063: return getName().equals(DERBYNETCLIENT.getName());
064: }
065:
066: /**
067: * Is this DB2's Universal JDBC
068: * @return
069: */
070: public boolean isDB2Client() {
071: return getName().equals(DB2CLIENT.getName());
072: }
073:
074: /**
075: * Get the name of the client
076: */
077: public String getName() {
078: return frameWork;
079: }
080:
081: /**
082: * Get JDBC driver class name.
083: *
084: * @return class name for JDBC driver.
085: */
086: public String getJDBCDriverName() {
087: return driverClassName;
088: }
089:
090: /**
091: * Get DataSource class name.
092: *
093: * @return class name for DataSource implementation.
094: */
095: public String getDataSourceClassName() {
096: return dsClassName;
097: }
098:
099: /**
100: * Return the base JDBC url.
101: * The JDBC base url specifies the protocol and possibly the subprotcol
102: * in the JDBC connection string.
103: *
104: * @return JDBC base url.
105: */
106: public String getUrlBase() {
107: return urlBase;
108: }
109:
110: /**
111: * Return string representation of this object.
112: *
113: * @return string representation of this object.
114: */
115: public String toString() {
116: return frameWork;
117: }
118:
119: /**
120: * Create a JDBC client definition.
121: */
122: private JDBCClient(String frameWork, String driverClassName,
123: String dataSourceClassName, String urlBase) {
124: this .frameWork = frameWork;
125: this .driverClassName = driverClassName;
126: this .dsClassName = dataSourceClassName;
127: this .urlBase = urlBase;
128: }
129:
130: private final String frameWork;
131: private final String driverClassName;
132: private final String dsClassName;
133: private final String urlBase;
134:
135: }
|