View Javadoc
1   /*
2    * This file is part of Waarp Project (named also Waarp or GG).
3    *
4    *  Copyright (c) 2019, Waarp SAS, 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 Waarp Project is free software: you can redistribute it and/or
9    * modify it under the terms of the GNU General Public License as published by
10   * the Free Software Foundation, either version 3 of the License, or (at your
11   * option) any later version.
12   *
13   * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY
14   * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15   * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16   *
17   *  You should have received a copy of the GNU General Public License along with
18   * Waarp . If not, see <http://www.gnu.org/licenses/>.
19   */
20  package org.waarp.common.database.model;
21  
22  import org.waarp.common.database.DbConstant;
23  import org.waarp.common.database.DbSession;
24  import org.waarp.common.database.exception.WaarpDatabaseNoConnectionException;
25  import org.waarp.common.database.exception.WaarpDatabaseNoDataException;
26  import org.waarp.common.database.exception.WaarpDatabaseSqlException;
27  import org.waarp.common.database.model.DbModelAbstract.DbTypeResolver;
28  
29  import java.sql.Connection;
30  import java.sql.SQLException;
31  
32  /**
33   * Empty DbModel
34   */
35  public class EmptyDbModel implements DbModel {
36  
37    /**
38     *
39     */
40    public EmptyDbModel() {
41      // nothing
42    }
43  
44    @Override
45    public final Connection getDbConnection(final String server,
46                                            final String user,
47                                            final String passwd)
48        throws SQLException {
49      return null;
50    }
51  
52    @Override
53    public final void releaseResources() {
54      // nothing
55    }
56  
57    @Override
58    public final int currentNumberOfPooledConnections() {
59      return 0;
60    }
61  
62    @Override
63    public final DbType getDbType() {
64      return DbType.none;
65    }
66  
67    @Override
68    public final DbTypeResolver getDbTypeResolver() {
69      return null;
70    }
71  
72    @Override
73    public final void createTables(final DbSession session)
74        throws WaarpDatabaseNoConnectionException {
75      // nothing
76    }
77  
78    @Override
79    public final void resetSequence(final DbSession session, final long newvalue)
80        throws WaarpDatabaseNoConnectionException {
81      // nothing
82    }
83  
84    @Override
85    public final long nextSequence(final DbSession dbSession)
86        throws WaarpDatabaseNoConnectionException, WaarpDatabaseSqlException,
87               WaarpDatabaseNoDataException {
88      return DbConstant.ILLEGALVALUE;
89    }
90  
91    @Override
92    public final void validConnection(final DbSession dbSession)
93        throws WaarpDatabaseNoConnectionException {
94      // nothing
95    }
96  
97    @Override
98    public final String limitRequest(final String allfields, final String request,
99                                     final int limit) {
100     return null;
101   }
102 
103   @Override
104   public final boolean upgradeDb(final DbSession session, final String version)
105       throws WaarpDatabaseNoConnectionException {
106     return true;
107   }
108 
109   @Override
110   public final boolean needUpgradeDb(final DbSession session,
111                                      final String version, final boolean tryFix)
112       throws WaarpDatabaseNoConnectionException {
113     return false;
114   }
115 
116 }