Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
 
 
 
 package org.apache.cayenne.modeler.util;
 
 import java.util.Map;
 
Contains mappings for guessing defaults for various adapter and JDBC settings.

Author(s):
Andrei Adamchik
 
 public class AdapterMapping {
 
     protected Map adapterToJDBCDriverMap;
     protected Map adapterToJDBCURLMap;
     protected Map jdbcDriverToAdapterMap;
     protected Map eofPluginToAdapterMap;
 
     public AdapterMapping() {
         this. = new HashMap();
         this. = new HashMap();
         this. = new HashMap();
         this. = new HashMap();
 
         initDefaults();
     }
 
     protected void initDefaults() {
         // TODO: make configuration external...
 
         // drivers
         .put("oracle.jdbc.driver.OracleDriver"OracleAdapter.class
                 .getName());
         .put("com.sybase.jdbc2.jdbc.SybDriver"SybaseAdapter.class
                 .getName());
         .put("com.mysql.jdbc.Driver"MySQLAdapter.class.getName());
         .put("com.ibm.db2.jcc.DB2Driver"DB2Adapter.class
                 .getName());
         
                 .put("org.hsqldb.jdbcDriver"HSQLDBAdapter.class.getName());
         .put("org.postgresql.Driver"PostgresAdapter.class
                 .getName());
         .put("com.openbase.jdbc.ObDriver"OpenBaseAdapter.class
                 .getName());
         .put(
                 "com.microsoft.jdbc.sqlserver.SQLServerDriver",
                 SQLServerAdapter.class.getName());
         .put(
                 "org.apache.derby.jdbc.EmbeddedDriver",
                 DerbyAdapter.class.getName());
         .put("jdbc.FrontBase.FBJDriver"FrontBaseAdapter.class
                 .getName());
         .put("com.ingres.jdbc.IngresDriver"IngresAdapter.class
                 .getName());
 
         // urls
         .put(
                 OracleAdapter.class.getName(),
                 "jdbc:oracle:thin:@localhost:1521:database");
         .put(
                 SybaseAdapter.class.getName(),
                 "jdbc:sybase:Tds:localhost:port/database");
         .put(
                 MySQLAdapter.class.getName(),
                 "jdbc:mysql://localhost/database");
         .put(
                 DB2Adapter.class.getName(),
                 "jdbc:db2://localhost:port/database");
        .put(
                HSQLDBAdapter.class.getName(),
                "jdbc:hsqldb:hsql://localhost/database");
        .put(
                PostgresAdapter.class.getName(),
                "jdbc:postgresql://localhost:5432/database");
        .put(
                OpenBaseAdapter.class.getName(),
                "jdbc:openbase://localhost/database");
        
                .put(
                        SQLServerAdapter.class.getName(),
                        "jdbc:microsoft:sqlserver://host;databaseName=database;SelectMethod=cursor");
        // TODO: embedded Derby Mode... change to client-server once we figure it out
        .put(
                DerbyAdapter.class.getName(),
                "jdbc:derby:testdb;create=true");
        .put(
                FrontBaseAdapter.class.getName(),
                "jdbc:FrontBase://localhost/database");
        .put(
                IngresAdapter.class.getName(),
                "jdbc:ingres://127.0.0.1:II7/database");
        // adapters
                OracleAdapter.class.getName(),
                "oracle.jdbc.driver.OracleDriver");
                SybaseAdapter.class.getName(),
                "com.sybase.jdbc2.jdbc.SybDriver");
        .put(MySQLAdapter.class.getName(), "com.mysql.jdbc.Driver");
                DB2Adapter.class.getName(),
                "com.ibm.db2.jcc.DB2Driver");
                .put(HSQLDBAdapter.class.getName(), "org.hsqldb.jdbcDriver");
                PostgresAdapter.class.getName(),
                "org.postgresql.Driver");
                OpenBaseAdapter.class.getName(),
                "com.openbase.jdbc.ObDriver");
                SQLServerAdapter.class.getName(),
                "com.microsoft.jdbc.sqlserver.SQLServerDriver");
                DerbyAdapter.class.getName(),
                "org.apache.derby.jdbc.EmbeddedDriver");
                FrontBaseAdapter.class.getName(),
                "jdbc.FrontBase.FBJDriver");
                IngresAdapter.class.getName(),
                "com.ingres.jdbc.IngresDriver");
        // EOF plugins...
        .put(
                "com.webobjects.jdbcadaptor.SybasePlugIn",
                SybaseAdapter.class.getName());
        .put(
                "com.webobjects.jdbcadaptor.MerantPlugIn",
                SQLServerAdapter.class.getName());
        .put(
                "com.webobjects.jdbcadaptor.MicrosoftPlugIn",
                SQLServerAdapter.class.getName());
        .put(
                "com.webobjects.jdbcadaptor.MySQLPlugIn",
                MySQLAdapter.class.getName());
        .put(
                "com.webobjects.jdbcadaptor.OraclePlugIn",
                OracleAdapter.class.getName());
        .put(
                "com.webobjects.jdbcadaptor.FrontbasePlugIn",
                FrontBaseAdapter.class.getName());
        .put("PostgresqlPlugIn"PostgresAdapter.class.getName());
    }
    public String jdbcURLForAdapter(String adapterClass) {
        return (String.get(adapterClass);
    }
    public String jdbcDriverForAdapter(String adapterClass) {
        return (String.get(adapterClass);
    }
    public String adapterForJDBCDriver(String driverClass) {
        return (String.get(driverClass);
    }
    public String adapterForEOFPlugin(String eofPlugin) {
        return (String.get(eofPlugin);
    }
    public String adapterForEOFPluginOrDriver(String eofPluginString jdbcDriver) {
        String adapter = adapterForEOFPlugin(eofPlugin);
        return (adapter != null) ? adapter : adapterForJDBCDriver(jdbcDriver);
    }
New to GrepCode? Check out our FAQ X