1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.kernel.dao.db;
24  
25  import com.liferay.portal.SystemException;
26  
27  import java.io.IOException;
28  
29  import java.sql.Connection;
30  import java.sql.SQLException;
31  
32  import java.util.List;
33  
34  import javax.naming.NamingException;
35  
36  /**
37   * <a href="DB.java.html"><b><i>View Source</i></b></a>
38   *
39   * @author Brian Wing Shun Chan
40   */
41  public interface DB {
42  
43      public static final int MINIMAL = 1;
44  
45      public static final int POPULATED = 0;
46  
47      public static final int SHARDED = 2;
48  
49      public static final String TYPE_DB2 = "db2";
50  
51      public static final String TYPE_DERBY = "derby";
52  
53      public static final String TYPE_FIREBIRD = "firebird";
54  
55      public static final String TYPE_HYPERSONIC = "hypersonic";
56  
57      public static final String TYPE_INFORMIX = "informix";
58  
59      public static final String TYPE_INGRES = "ingres";
60  
61      public static final String TYPE_INTERBASE = "interbase";
62  
63      public static final String TYPE_JDATASTORE = "jdatastore";
64  
65      public static final String TYPE_MYSQL = "mysql";
66  
67      public static final String TYPE_ORACLE = "oracle";
68  
69      public static final String TYPE_POSTGRESQL = "postgresql";
70  
71      public static final String TYPE_SAP = "sap";
72  
73      public static final String TYPE_SQLSERVER = "sqlserver";
74  
75      public static final String TYPE_SYBASE = "sybase";
76  
77      public static final String[] TYPE_ALL = {
78          TYPE_DB2, TYPE_DERBY, TYPE_FIREBIRD, TYPE_HYPERSONIC, TYPE_INFORMIX,
79          TYPE_INGRES, TYPE_INTERBASE, TYPE_JDATASTORE, TYPE_MYSQL, TYPE_ORACLE,
80          TYPE_POSTGRESQL, TYPE_SAP, TYPE_SQLSERVER, TYPE_SYBASE
81      };
82  
83      public void buildCreateFile(String databaseName) throws IOException;
84  
85      public void buildCreateFile(String databaseName, int population)
86          throws IOException;
87  
88      public String buildSQL(String template) throws IOException;
89  
90      public void buildSQLFile(String fileName) throws IOException;
91  
92      public List<Index> getIndexes() throws SQLException;
93  
94      public String getTemplateFalse();
95  
96      public String getTemplateTrue();
97  
98      public String getType();
99  
100     public long increment() throws SystemException;
101 
102     public boolean isSupportsAlterColumnName();
103 
104     public boolean isSupportsAlterColumnType();
105 
106     public boolean isSupportsDateMilliseconds();
107 
108     public boolean isSupportsScrollableResults();
109 
110     public boolean isSupportsStringCaseSensitiveQuery();
111 
112     public boolean isSupportsUpdateWithInnerJoin();
113 
114     public void runSQL(String sql) throws IOException, SQLException;
115 
116     public void runSQL(Connection con, String sql)
117         throws IOException, SQLException;
118 
119     public void runSQL(String[] sqls) throws IOException, SQLException;
120 
121     public void runSQL(Connection con, String[] sqls)
122         throws IOException, SQLException;
123 
124     public void runSQLTemplate(String path)
125         throws IOException, NamingException, SQLException;
126 
127     public void runSQLTemplate(String path, boolean failOnError)
128         throws IOException, NamingException, SQLException;
129 
130     public void runSQLTemplateString(
131             String template, boolean evaluate, boolean failOnError)
132         throws IOException, NamingException, SQLException;
133 
134     public void setSupportsStringCaseSensitiveQuery(
135         boolean supportsStringCaseSensitiveQuery);
136 
137     public void updateIndexes(
138             String tablesSQL, String indexesSQL, String indexesProperties,
139             boolean dropStaleIndexes)
140         throws IOException, SQLException;
141 
142 }