1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.kernel.dao.db;
16  
17  import com.liferay.portal.kernel.exception.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 isSupportsScrollableResults();
104 
105     public boolean isSupportsStringCaseSensitiveQuery();
106 
107     public boolean isSupportsUpdateWithInnerJoin();
108 
109     public void runSQL(String sql) throws IOException, SQLException;
110 
111     public void runSQL(Connection con, String sql)
112         throws IOException, SQLException;
113 
114     public void runSQL(String[] sqls) throws IOException, SQLException;
115 
116     public void runSQL(Connection con, String[] sqls)
117         throws IOException, SQLException;
118 
119     public void runSQLTemplate(String path)
120         throws IOException, NamingException, SQLException;
121 
122     public void runSQLTemplate(String path, boolean failOnError)
123         throws IOException, NamingException, SQLException;
124 
125     public void runSQLTemplateString(
126             String template, boolean evaluate, boolean failOnError)
127         throws IOException, NamingException, SQLException;
128 
129     public void setSupportsStringCaseSensitiveQuery(
130         boolean supportsStringCaseSensitiveQuery);
131 
132     public void updateIndexes(
133             String tablesSQL, String indexesSQL, String indexesProperties,
134             boolean dropStaleIndexes)
135         throws IOException, SQLException;
136 
137 }