View Javadoc

1   /**
2      This file is part of GoldenGate Project (named also GoldenGate or GG).
3   
4      Copyright 2009, Frederic Bregier, and individual contributors by the @author
5      tags. See the COPYRIGHT.txt in the distribution for a full listing of
6      individual contributors.
7   
8      All GoldenGate Project is free software: you can redistribute it and/or 
9      modify it under the terms of the GNU General Public License as published 
10     by the Free Software Foundation, either version 3 of the License, or
11     (at your option) any later version.
12  
13     GoldenGate is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17  
18     You should have received a copy of the GNU General Public License
19     along with GoldenGate .  If not, see <http://www.gnu.org/licenses/>.
20   */
21  package openr66.database.model;
22  
23  import goldengate.common.database.DbAdmin;
24  import goldengate.common.database.exception.GoldenGateDatabaseNoConnectionException;
25  import goldengate.common.database.model.DbType;
26  
27  
28  /**
29   * Factory to store the Database Model object
30   *
31   * @author Frederic Bregier
32   *
33   */
34  public class DbModelFactory extends goldengate.common.database.model.DbModelFactory {
35  
36      /**
37       * Initialize the Database Model according to arguments.
38       * @param dbdriver
39       * @param dbserver
40       * @param dbuser
41       * @param dbpasswd
42       * @param write
43       * @throws GoldenGateDatabaseNoConnectionException
44       */
45      public static DbAdmin initialize(String dbdriver, String dbserver,
46              String dbuser, String dbpasswd, boolean write)
47              throws GoldenGateDatabaseNoConnectionException {
48          DbType type = DbType.getFromDriver(dbdriver);
49          switch (type) {
50              case H2:
51                  dbModel = new DbModelH2(dbserver, dbuser, dbpasswd);
52                  break;
53              case Oracle:
54                  dbModel = new DbModelOracle(dbserver, dbuser, dbpasswd);
55                  break;
56              case PostGreSQL:
57                  dbModel = new DbModelPostgresql();
58                  break;
59              case MySQL:
60                  dbModel = new DbModelMysql(dbserver, dbuser, dbpasswd);
61                  break;
62              default:
63                  throw new GoldenGateDatabaseNoConnectionException(
64                          "TypeDriver unknown: " + type);
65          }
66          return new DbAdmin(type, dbserver, dbuser, dbpasswd,
67                  write);
68      }
69  }