001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.visualweb.dataconnectivity.utils;
043:
044: import java.util.LinkedList;
045: import java.util.List;
046: import java.util.Set;
047: import java.util.TreeSet;
048: import java.util.Vector;
049:
050: import org.netbeans.api.db.explorer.JDBCDriver;
051: import org.netbeans.api.db.explorer.JDBCDriverManager;
052:
053: public class DriverListUtil {
054:
055: private static List drivers = new LinkedList();
056: private static List urls = new LinkedList();
057: private static List names = new LinkedList();
058:
059: //private default constructor -> singleton
060: private DriverListUtil() {
061: }
062:
063: static {
064: names.add("IBM DB2 (net)");
065: drivers.add("COM.ibm.db2.jdbc.net.DB2Driver");
066: urls.add("jdbc:db2://<HOST>:<PORT>/<DB>");
067:
068: names.add("IBM DB2 (local)");
069: drivers.add("COM.ibm.db2.jdbc.app.DB2Driver");
070: urls.add("jdbc:db2:<DB>");
071:
072: names.add("JDBC-ODBC Bridge");
073: drivers.add("sun.jdbc.odbc.JdbcOdbcDriver");
074: urls.add("jdbc:odbc:<DB>");
075:
076: names.add("Microsoft SQL Server (Weblogic driver)");
077: drivers.add("weblogic.jdbc.mssqlserver4.Driver");
078: urls.add("jdbc:weblogic:mssqlserver4:<DB>@<HOST>:<PORT>");
079:
080: names.add("Oracle"); //thin
081: drivers.add("oracle.jdbc.OracleDriver");
082: urls.add("jdbc:oracle:thin:@<HOST>:<PORT>:<SID>");
083:
084: names.add("PointBase"); //Network Server
085: drivers.add("com.pointbase.jdbc.jdbcUniversalDriver");
086: urls.add("jdbc:pointbase://<HOST>[:<PORT>]/<DB>");
087:
088: names.add("PointBase"); //Embedded Server
089: drivers.add("com.pointbase.jdbc.jdbcUniversalDriver");
090: urls.add("jdbc:pointbase://embedded[:<PORT>]/<DB>");
091:
092: names.add("PointBase"); //Mobile Edition
093: drivers.add("com.pointbase.jdbc.jdbcUniversalDriver");
094: urls.add("jdbc:pointbase:<DB>");
095:
096: names.add("Cloudscape");
097: drivers.add("COM.cloudscape.core.JDBCDriver");
098: urls.add("jdbc:cloudscape:<DB>");
099:
100: names.add("Cloudscape RMI");
101: drivers.add("RmiJdbc.RJDriver");
102: urls.add("jdbc:rmi://<HOST>:<PORT>/jdbc:cloudscape:<DB>");
103:
104: names.add("Java DB (Embedded)");
105: drivers.add("org.apache.derby.jdbc.EmbeddedDriver");
106: urls.add("jdbc:derby:<DB>");
107:
108: names.add("Java DB (Network)");
109: drivers.add("org.apache.derby.jdbc.ClientDriver");
110: urls
111: .add("jdbc:derby://<HOST>[:<PORT>]/databaseName[;attr1=value1[;...]]");
112:
113: names.add("DB2 JDBC");
114: drivers.add("com.ibm.db2.jcc.DB2Driver");
115: urls.add("jdbc:db2://<hostname>:<port>/<database>");
116:
117: names.add("Firebird (JCA/JDBC driver)");
118: drivers.add("org.firebirdsql.jdbc.FBDriver");
119: urls.add("jdbc:firebirdsql:[//<HOST>[:<PORT>]/]<DB>");
120:
121: names.add("FirstSQL/J"); //Enterprise Server Edition
122: drivers.add("COM.FirstSQL.Dbcp.DbcpDriver");
123: urls.add("jdbc:dbcp://<HOST>:<PORT>");
124:
125: names.add("FirstSQL/J"); //Professional Edition
126: drivers.add("COM.FirstSQL.Dbcp.DbcpDriver");
127: urls.add("jdbc:dbcp://local");
128:
129: names.add("IBM DB2 (DataDirect Connect for JDBC)");
130: drivers.add("com.ddtek.jdbc.db2.DB2Driver");
131: urls
132: .add("jdbc:datadirect:db2://<HOST>:<PORT>[;databaseName=<DB>]");
133:
134: names.add("IDS Server");
135: drivers.add("ids.sql.IDSDriver");
136: urls.add("jdbc:ids://<HOST>:<PORT>/conn?dsn='<ODBC_DSN_NAME>'");
137:
138: names.add("Informix Dynamic Server");
139: drivers.add("com.informix.jdbc.IfxDriver");
140: urls
141: .add("jdbc:informix-sqli://<HOST>:<PORT>/<DB>:INFORMIXSERVER=<SERVER_NAME>");
142:
143: names
144: .add("Informix Dynamic Server (DataDirect Connect for JDBC)");
145: drivers.add("com.ddtek.jdbc.informix.InformixDriver");
146: urls
147: .add("jdbc:datadirect:informix://<HOST>:<PORT>;informixServer=<SERVER_NAME>;databaseName=<DB>");
148:
149: names.add("InstantDB (v3.13 and earlier)");
150: drivers.add("jdbc.idbDriver");
151: urls.add("jdbc:idb:<DB>");
152:
153: names.add("InstantDB (v3.14 and later)");
154: drivers.add("org.enhydra.instantdb.jdbc.idbDriver");
155: urls.add("jdbc:idb:<DB>");
156:
157: names.add("Interbase (InterClient driver)");
158: drivers.add("interbase.interclient.Driver");
159: urls.add("jdbc:interbase://<HOST>/<DB>");
160:
161: names.add("HSQLDB"); //(server)
162: drivers.add("org.hsqldb.jdbcDriver");
163: urls.add("jdbc:hsqldb:hsql://<HOST>[:<PORT>]");
164:
165: names.add("HSQLDB"); //(standalone)
166: drivers.add("org.hsqldb.jdbcDriver");
167: urls.add("jdbc:hsqldb:<DB>");
168:
169: names.add("HSQLDB"); //(webserver)
170: drivers.add("org.hsqldb.jdbcDriver");
171: urls.add("jdbc:hsqldb:http://<HOST>[:<PORT>]");
172:
173: names.add("HSQLDB"); //(in-memory)
174: drivers.add("org.hsqldb.jdbcDriver");
175: urls.add("jdbc:hsqldb:.");
176:
177: names.add("Hypersonic SQL (v1.2 and earlier)");
178: drivers.add("hSql.hDriver");
179: urls.add("jdbc:HypersonicSQL:<DB>");
180:
181: names.add("Hypersonic SQL (v1.3 and later)");
182: drivers.add("org.hsql.jdbcDriver");
183: urls.add("jdbc:HypersonicSQL:<DB>");
184:
185: names.add("jTDS");
186: drivers.add("net.sourceforge.jtds.jdbc.Driver");
187: urls
188: .add("jdbc:jtds:sqlserver://<server>[:<PORT>][/<DATABASE>]");
189:
190: names.add("jTDS");
191: drivers.add("net.sourceforge.jtds.jdbc.Driver");
192: urls.add("jdbc:jtds:sybase://<server>[:<PORT>][/<DATABASE>]");
193:
194: names.add("Mckoi SQL Database"); //(server)
195: drivers.add("com.mckoi.JDBCDriver");
196: urls.add("jdbc:mckoi://<HOST>[:<PORT>]");
197:
198: names.add("Mckoi SQL Database"); //(standalone)
199: drivers.add("com.mckoi.JDBCDriver");
200: urls.add("jdbc:mckoi:local://<DB>");
201:
202: names.add("Microsoft SQL Server (DataDirect Connect for JDBC)");
203: drivers.add("com.ddtek.jdbc.sqlserver.SQLServerDriver");
204: urls
205: .add("jdbc:datadirect:sqlserver://<HOST>:<PORT>[;databaseName=<DB>]");
206:
207: names.add("Microsoft SQL Server (JTurbo driver)");
208: drivers.add("com.ashna.jturbo.driver.Driver");
209: urls.add("jdbc:JTurbo://<HOST>:<PORT>/<DB>");
210:
211: names.add("Microsoft SQL Server (Sprinta driver)");
212: drivers.add("com.inet.tds.TdsDriver");
213: urls.add("jdbc:inetdae:<HOST>:<PORT>?database=<DB>");
214:
215: names.add("Microsoft SQL Server 2000 (Microsoft driver)");
216: drivers.add("com.microsoft.jdbc.sqlserver.SQLServerDriver");
217: urls
218: .add("jdbc:microsoft:sqlserver://<HOST>:<PORT>[;DatabaseName=<DB>]");
219:
220: names.add("Microsoft SQL Server 2005");
221: drivers.add("com.microsoft.sqlserver.jdbc.SQLServerDriver");
222: urls
223: .add("jdbc:sqlserver://<hostname>:<PORT>;databaseName=<database>;selectMethod=cursor");
224:
225: names.add("MySQL (Connector/J driver)");
226: drivers.add("com.mysql.jdbc.Driver");
227: urls.add("jdbc:mysql://<HOST>:<PORT>/<DB>");
228:
229: names.add("MySQL (MM.MySQL driver)");
230: drivers.add("org.gjt.mm.mysql.Driver");
231: urls.add("jdbc:mysql://<HOST>:<PORT>/<DB>");
232:
233: names.add("Oracle"); //OCI 8i
234: drivers.add("oracle.jdbc.driver.OracleDriver");
235: urls.add("jdbc:oracle:oci8:@<SID>");
236:
237: names.add("Oracle"); //OCI 9i
238: drivers.add("oracle.jdbc.driver.OracleDriver");
239: urls.add("jdbc:oracle:oci:@<SID>");
240:
241: names.add("Oracle (DataDirect Connect for JDBC)");
242: drivers.add("com.ddtek.jdbc.oracle.OracleDriver");
243: urls.add("jdbc:datadirect:oracle://<HOST>:<PORT>;SID=<SID>");
244:
245: names.add("PostgreSQL (v6.5 and earlier)");
246: drivers.add("postgresql.Driver");
247: urls.add("jdbc:postgresql://<HOST>:<PORT>/<DB>");
248:
249: names.add("PostgreSQL (v7.0 and later)");
250: drivers.add("org.postgresql.Driver");
251: urls.add("jdbc:postgresql://<HOST>:<PORT>/<DB>");
252:
253: names.add("Quadcap Embeddable Database");
254: drivers.add("com.quadcap.jdbc.JdbcDriver");
255: urls.add("jdbc:qed:<DB>");
256:
257: names.add("Sybase (jConnect 4.2 and earlier)");
258: drivers.add("com.sybase.jdbc.SybDriver");
259: urls.add("jdbc:sybase:Tds:<HOST>:<PORT>");
260:
261: names.add("Sybase (jConnect 5.2)");
262: drivers.add("com.sybase.jdbc2.jdbc.SybDriver");
263: urls.add("jdbc:sybase:Tds:<HOST>:<PORT>");
264:
265: names.add("Sybase (DataDirect Connect for JDBC)");
266: drivers.add("com.ddtek.jdbc.sybase.SybaseDriver");
267: urls
268: .add("jdbc:datadirect:sybase://<HOST>:<PORT>[;databaseName=<DB>]");
269:
270: // Following four entries for drivers to be included in Java Studio Enterprise 7 (Bow)
271: names.add("Microsoft SQL Server Driver");
272: drivers.add("com.sun.sql.jdbc.sqlserver.SQLServerDriver");
273: urls.add("jdbc:sun:sqlserver://server_name[:portNumber]");
274:
275: names.add("DB2 Driver");
276: drivers.add("com.sun.sql.jdbc.db2.DB2Driver");
277: urls
278: .add("jdbc:sun:db2://server_name:portNumber;databaseName=DATABASENAME");
279:
280: names.add("Oracle Driver");
281: drivers.add("com.sun.sql.jdbc.oracle.OracleDriver");
282: urls
283: .add("jdbc:sun:oracle://server_name[:portNumber][;SID=DATABASENAME]");
284:
285: names.add("Sybase Driver");
286: drivers.add("com.sun.sql.jdbc.sybase.SybaseDriver");
287: urls.add("jdbc:sun:sybase://server_name[:portNumber]");
288: }
289:
290: public static Set getDrivers() {
291: return new TreeSet(drivers);
292: }
293:
294: public static List getURLs(String drv) {
295: List ret = new LinkedList();
296:
297: for (int i = 0; i < drivers.size(); i++)
298: if (((String) drivers.get(i)).equals(drv))
299: ret.add(urls.get(i));
300:
301: return ret;
302: }
303:
304: public static String getName(String drv) {
305: for (int i = 0; i < drivers.size(); i++)
306: if (((String) drivers.get(i)).equals(drv))
307: return (String) names.get(i);
308:
309: return "";
310: }
311:
312: public static String getDriver(String name) {
313: for (int i = 0; i < names.size(); i++)
314: if (((String) names.get(i)).equals(name))
315: return (String) drivers.get(i);
316:
317: return "";
318: }
319:
320: public static String findFreeName(String name) {
321: String ret;
322: Vector names = new Vector();
323: JDBCDriver[] drivers = JDBCDriverManager.getDefault()
324: .getDrivers();
325: for (int i = 0; i < drivers.length; i++)
326: names.add(drivers[i].getDisplayName());
327:
328: if (names.contains(name))
329: for (int i = 1;; i++) {
330: ret = name + " (" + i + ")";
331: if (!names.contains(ret))
332: return ret;
333: }
334: else
335: return name;
336: }
337: }
|