001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.kernel.dao.db;
016    
017    import com.liferay.portal.kernel.exception.SystemException;
018    
019    import java.io.IOException;
020    
021    import java.sql.Connection;
022    import java.sql.SQLException;
023    
024    import java.util.List;
025    
026    import javax.naming.NamingException;
027    
028    /**
029     * @author Brian Wing Shun Chan
030     */
031    public interface DB {
032    
033            public static final int MINIMAL = 1;
034    
035            public static final int POPULATED = 0;
036    
037            public static final int SHARDED = 2;
038    
039            public static final String TYPE_DB2 = "db2";
040    
041            public static final String TYPE_DERBY = "derby";
042    
043            public static final String TYPE_FIREBIRD = "firebird";
044    
045            public static final String TYPE_HYPERSONIC = "hypersonic";
046    
047            public static final String TYPE_INFORMIX = "informix";
048    
049            public static final String TYPE_INGRES = "ingres";
050    
051            public static final String TYPE_INTERBASE = "interbase";
052    
053            public static final String TYPE_JDATASTORE = "jdatastore";
054    
055            public static final String TYPE_MYSQL = "mysql";
056    
057            public static final String TYPE_ORACLE = "oracle";
058    
059            public static final String TYPE_POSTGRESQL = "postgresql";
060    
061            public static final String TYPE_SAP = "sap";
062    
063            public static final String TYPE_SQLSERVER = "sqlserver";
064    
065            public static final String TYPE_SYBASE = "sybase";
066    
067            public static final String[] TYPE_ALL = {
068                    TYPE_DB2, TYPE_DERBY, TYPE_FIREBIRD, TYPE_HYPERSONIC, TYPE_INFORMIX,
069                    TYPE_INGRES, TYPE_INTERBASE, TYPE_JDATASTORE, TYPE_MYSQL, TYPE_ORACLE,
070                    TYPE_POSTGRESQL, TYPE_SAP, TYPE_SQLSERVER, TYPE_SYBASE
071            };
072    
073            public void buildCreateFile(String sqlDir, String databaseName)
074                    throws IOException;
075    
076            public void buildCreateFile(
077                            String sqlDir, String databaseName, int population)
078                    throws IOException;
079    
080            public String buildSQL(String template) throws IOException;
081    
082            public void buildSQLFile(String sqlDir, String fileName)
083                    throws IOException;
084    
085            public List<Index> getIndexes() throws SQLException;
086    
087            public String getTemplateFalse();
088    
089            public String getTemplateTrue();
090    
091            public String getType();
092    
093            public long increment() throws SystemException;
094    
095            public boolean isSupportsAlterColumnName();
096    
097            public boolean isSupportsAlterColumnType();
098    
099            public boolean isSupportsDateMilliseconds();
100    
101            public boolean isSupportsInlineDistinct();
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    }