JDBCAdapterFactory.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */


  20. package org.openspcoop2.utils.jdbc;

  21. import org.openspcoop2.utils.TipiDatabase;

  22. /**
  23.  * Factory degli oggetti SQLQueryObject
  24.  *
  25.  *
  26.  * @author Poli Andrea (apoli@link.it)
  27.  * @author $Author$
  28.  * @version $Rev$, $Date$
  29.  */

  30. public class JDBCAdapterFactory {

  31.     public static IJDBCAdapter createJDBCAdapter(TipiDatabase tipoDatabase) throws JDBCAdapterException {
  32.         IJDBCAdapter jdbcAdapter = null;

  33.         if (TipiDatabase.POSTGRESQL.equals(tipoDatabase)) {
  34.             jdbcAdapter = new BytesJDBCAdapter(tipoDatabase);
  35.         } else if (TipiDatabase.MYSQL.equals(tipoDatabase)) {
  36.             jdbcAdapter = new BlobJDBCAdapter(tipoDatabase);
  37.         } else if (TipiDatabase.ORACLE.equals(tipoDatabase)) {
  38.             jdbcAdapter = new BlobJDBCAdapter(tipoDatabase);
  39.         } else if (TipiDatabase.HSQL.equals(tipoDatabase)) {
  40.             jdbcAdapter = new BytesJDBCAdapter(tipoDatabase);
  41.         } else if (TipiDatabase.DERBY.equals(tipoDatabase)) {
  42.             jdbcAdapter = new BytesJDBCAdapter(tipoDatabase);
  43.         } else if ( TipiDatabase.SQLSERVER.equals(tipoDatabase) ) {
  44.             jdbcAdapter = new StreamJDBCAdapter(tipoDatabase);
  45.         } else if ( TipiDatabase.DB2.equals(tipoDatabase) ) {
  46.             jdbcAdapter = new BlobJDBCAdapter(tipoDatabase);
  47.         } else{
  48.             throw new JDBCAdapterException("Tipo database non gestito ["+tipoDatabase+"]");
  49.         }

  50.         return jdbcAdapter;
  51.     }
  52.    
  53.     public static IJDBCAdapter createJDBCAdapter(String tipoDatabase) throws JDBCAdapterException {
  54.         return JDBCAdapterFactory.createJDBCAdapter(TipiDatabase.toEnumConstant(tipoDatabase));
  55.     }

  56. }