001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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    import java.util.Set;
026    
027    import javax.naming.NamingException;
028    
029    /**
030     * @author Brian Wing Shun Chan
031     */
032    public interface DB {
033    
034            public static final int MINIMAL = 1;
035    
036            public static final int POPULATED = 0;
037    
038            public static final int SHARDED = 2;
039    
040            public static final String[] TYPE_ALL = {
041                    DB.TYPE_DB2, DB.TYPE_DERBY, DB.TYPE_FIREBIRD, DB.TYPE_HYPERSONIC,
042                    DB.TYPE_INFORMIX, DB.TYPE_INGRES, DB.TYPE_INTERBASE, DB.TYPE_JDATASTORE,
043                    DB.TYPE_MYSQL, DB.TYPE_ORACLE, DB.TYPE_POSTGRESQL, DB.TYPE_SAP,
044                    DB.TYPE_SQLSERVER, DB.TYPE_SYBASE
045            };
046    
047            public static final String TYPE_DB2 = "db2";
048    
049            public static final String TYPE_DERBY = "derby";
050    
051            public static final String TYPE_FIREBIRD = "firebird";
052    
053            public static final String TYPE_HYPERSONIC = "hypersonic";
054    
055            public static final String TYPE_INFORMIX = "informix";
056    
057            public static final String TYPE_INGRES = "ingres";
058    
059            public static final String TYPE_INTERBASE = "interbase";
060    
061            public static final String TYPE_JDATASTORE = "jdatastore";
062    
063            public static final String TYPE_MYSQL = "mysql";
064    
065            public static final String TYPE_ORACLE = "oracle";
066    
067            public static final String TYPE_POSTGRESQL = "postgresql";
068    
069            public static final String TYPE_SAP = "sap";
070    
071            public static final String TYPE_SQLSERVER = "sqlserver";
072    
073            public static final String TYPE_SYBASE = "sybase";
074    
075            void addIndexes(
076                            Connection con, String indexesSQL, Set<String> validIndexNames)
077                    throws IOException;
078    
079            public void buildCreateFile(String sqlDir, String databaseName)
080                    throws IOException;
081    
082            public void buildCreateFile(
083                            String sqlDir, String databaseName, int population)
084                    throws IOException;
085    
086            public String buildSQL(String template) throws IOException;
087    
088            public void buildSQLFile(String sqlDir, String fileName)
089                    throws IOException;
090    
091            public List<Index> getIndexes(Connection con) throws SQLException;
092    
093            public String getTemplateFalse();
094    
095            public String getTemplateTrue();
096    
097            public String getType();
098    
099            public long increment() throws SystemException;
100    
101            public long increment(String name) throws SystemException;
102    
103            public boolean isSupportsAlterColumnName();
104    
105            public boolean isSupportsAlterColumnType();
106    
107            public boolean isSupportsDateMilliseconds();
108    
109            public boolean isSupportsInlineDistinct();
110    
111            public boolean isSupportsScrollableResults();
112    
113            public boolean isSupportsStringCaseSensitiveQuery();
114    
115            public boolean isSupportsUpdateWithInnerJoin();
116    
117            public void runSQL(Connection con, String sql)
118                    throws IOException, SQLException;
119    
120            public void runSQL(Connection con, String[] sqls)
121                    throws IOException, SQLException;
122    
123            public void runSQL(String sql) throws IOException, SQLException;
124    
125            public void runSQL(String[] sqls) throws IOException, SQLException;
126    
127            public void runSQLTemplate(String path)
128                    throws IOException, NamingException, SQLException;
129    
130            public void runSQLTemplate(String path, boolean failOnError)
131                    throws IOException, NamingException, SQLException;
132    
133            public void runSQLTemplateString(
134                            String template, boolean evaluate, boolean failOnError)
135                    throws IOException, NamingException, SQLException;
136    
137            public void setSupportsStringCaseSensitiveQuery(
138                    boolean supportsStringCaseSensitiveQuery);
139    
140            public void updateIndexes(
141                            Connection con, String tablesSQL, String indexesSQL,
142                            String indexesProperties, boolean dropStaleIndexes)
143                    throws IOException, SQLException;
144    
145    }