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;
 
 import  org.apache.cayenne.dba.db2.DB2Adapter;
 import  org.apache.cayenne.dba.derby.DerbyAdapter;
 import  org.apache.cayenne.dba.frontbase.FrontBaseAdapter;
 import  org.apache.cayenne.dba.h2.H2Adapter;
 import  org.apache.cayenne.dba.hsqldb.HSQLDBAdapter;
 import  org.apache.cayenne.dba.ingres.IngresAdapter;
 import  org.apache.cayenne.dba.mysql.MySQLAdapter;
 import  org.apache.cayenne.dba.openbase.OpenBaseAdapter;
 import  org.apache.cayenne.dba.oracle.OracleAdapter;
 import  org.apache.cayenne.dba.postgres.PostgresAdapter;
 import  org.apache.cayenne.dba.sqlite.SQLiteAdapter;
 import  org.apache.cayenne.dba.sqlserver.SQLServerAdapter;
 import  org.apache.cayenne.dba.sybase.SybaseAdapter;

Contains mappings for guessing defaults for various adapter and JDBC settings.
 
 public class AdapterMapping {
 
     protected Map<StringStringadapterToJDBCDriverMap;
     protected Map<StringStringadapterToJDBCURLMap;
     protected Map<StringStringjdbcDriverToAdapterMap;
     protected Map<StringStringeofPluginToAdapterMap;
 
     public AdapterMapping() {
         this. = new HashMap<StringString>();
         this. = new HashMap<StringString>();
         this. = new HashMap<StringString>();
         this. = new HashMap<StringString>();
 
         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.h2.Driver", H2Adapter.class.getName());
         .put("org.postgresql.Driver", PostgresAdapter.class
                 .getName());
         .put("com.openbase.jdbc.ObDriver", OpenBaseAdapter.class
                 .getName());
         .put(
                 "com.microsoft.sqlserver.jdbc.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());
         .put("org.sqlite.JDBC", SQLiteAdapter.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(
                H2Adapter.class.getName(),
                "jdbc:h2:mem:database;MVCC=TRUE");
        .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");
        .put(SQLiteAdapter.class.getName(), "jdbc:sqlite:testdb");
        // 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");
        .put(H2Adapter.class.getName(), "org.h2.Driver");
                PostgresAdapter.class.getName(),
                "org.postgresql.Driver");
                OpenBaseAdapter.class.getName(),
                "com.openbase.jdbc.ObDriver");
                SQLServerAdapter.class.getName(),
                "com.microsoft.sqlserver.jdbc.SQLServerDriver");
                DerbyAdapter.class.getName(),
                "org.apache.derby.jdbc.EmbeddedDriver");
                FrontBaseAdapter.class.getName(),
                "jdbc.FrontBase.FBJDriver");
                IngresAdapter.class.getName(),
                "com.ingres.jdbc.IngresDriver");
        .put(SQLiteAdapter.class.getName(), "org.sqlite.JDBC");
        // 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 .get(adapterClass);
    }
    public String jdbcDriverForAdapter(String adapterClass) {
        return .get(adapterClass);
    }
    public String adapterForJDBCDriver(String driverClass) {
        return .get(driverClass);
    }
    public String adapterForEOFPlugin(String eofPlugin) {
        return .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