1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.kernel.dao.db;
16  
17  import com.liferay.portal.SystemException;
18  
19  import java.io.IOException;
20  
21  import java.sql.Connection;
22  import java.sql.SQLException;
23  
24  import java.util.List;
25  
26  import javax.naming.NamingException;
27  
28  /**
29   * <a href="DB.java.html"><b><i>View Source</i></b></a>
30   *
31   * @author Brian Wing Shun Chan
32   */
33  public interface DB {
34  
35      public static final int MINIMAL = 1;
36  
37      public static final int POPULATED = 0;
38  
39      public static final int SHARDED = 2;
40  
41      public static final String TYPE_DB2 = "db2";
42  
43      public static final String TYPE_DERBY = "derby";
44  
45      public static final String TYPE_FIREBIRD = "firebird";
46  
47      public static final String TYPE_HYPERSONIC = "hypersonic";
48  
49      public static final String TYPE_INFORMIX = "informix";
50  
51      public static final String TYPE_INGRES = "ingres";
52  
53      public static final String TYPE_INTERBASE = "interbase";
54  
55      public static final String TYPE_JDATASTORE = "jdatastore";
56  
57      public static final String TYPE_MYSQL = "mysql";
58  
59      public static final String TYPE_ORACLE = "oracle";
60  
61      public static final String TYPE_POSTGRESQL = "postgresql";
62  
63      public static final String TYPE_SAP = "sap";
64  
65      public static final String TYPE_SQLSERVER = "sqlserver";
66  
67      public static final String TYPE_SYBASE = "sybase";
68  
69      public static final String[] TYPE_ALL = {
70          TYPE_DB2, TYPE_DERBY, TYPE_FIREBIRD, TYPE_HYPERSONIC, TYPE_INFORMIX,
71          TYPE_INGRES, TYPE_INTERBASE, TYPE_JDATASTORE, TYPE_MYSQL, TYPE_ORACLE,
72          TYPE_POSTGRESQL, TYPE_SAP, TYPE_SQLSERVER, TYPE_SYBASE
73      };
74  
75      public void buildCreateFile(String sqlDir, String databaseName)
76          throws IOException;
77  
78      public void buildCreateFile(
79              String sqlDir, String databaseName, int population)
80          throws IOException;
81  
82      public String buildSQL(String template) throws IOException;
83  
84      public void buildSQLFile(String sqlDir, String fileName)
85          throws IOException;
86  
87      public List<Index> getIndexes() throws SQLException;
88  
89      public String getTemplateFalse();
90  
91      public String getTemplateTrue();
92  
93      public String getType();
94  
95      public long increment() throws SystemException;
96  
97      public boolean isSupportsAlterColumnName();
98  
99      public boolean isSupportsAlterColumnType();
100 
101     public boolean isSupportsDateMilliseconds();
102 
103     public boolean isSupportsInlineDistinct();
104 
105     public boolean isSupportsScrollableResults();
106 
107     public boolean isSupportsStringCaseSensitiveQuery();
108 
109     public boolean isSupportsUpdateWithInnerJoin();
110 
111     public void runSQL(String sql) throws IOException, SQLException;
112 
113     public void runSQL(Connection con, String sql)
114         throws IOException, SQLException;
115 
116     public void runSQL(String[] sqls) throws IOException, SQLException;
117 
118     public void runSQL(Connection con, String[] sqls)
119         throws IOException, SQLException;
120 
121     public void runSQLTemplate(String path)
122         throws IOException, NamingException, SQLException;
123 
124     public void runSQLTemplate(String path, boolean failOnError)
125         throws IOException, NamingException, SQLException;
126 
127     public void runSQLTemplateString(
128             String template, boolean evaluate, boolean failOnError)
129         throws IOException, NamingException, SQLException;
130 
131     public void setSupportsStringCaseSensitiveQuery(
132         boolean supportsStringCaseSensitiveQuery);
133 
134     public void updateIndexes(
135             String tablesSQL, String indexesSQL, String indexesProperties,
136             boolean dropStaleIndexes)
137         throws IOException, SQLException;
138 
139 }