001    /**
002     * Copyright (c) 2000-2012 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    
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_ALL = {
040                    DB.TYPE_DB2, DB.TYPE_DERBY, DB.TYPE_FIREBIRD, DB.TYPE_HYPERSONIC,
041                    DB.TYPE_INFORMIX, DB.TYPE_INGRES, DB.TYPE_INTERBASE, DB.TYPE_JDATASTORE,
042                    DB.TYPE_MYSQL, DB.TYPE_ORACLE, DB.TYPE_POSTGRESQL, DB.TYPE_SAP,
043                    DB.TYPE_SQLSERVER, DB.TYPE_SYBASE
044            };
045    
046            public static final String TYPE_DB2 = "db2";
047    
048            public static final String TYPE_DERBY = "derby";
049    
050            public static final String TYPE_FIREBIRD = "firebird";
051    
052            public static final String TYPE_HYPERSONIC = "hypersonic";
053    
054            public static final String TYPE_INFORMIX = "informix";
055    
056            public static final String TYPE_INGRES = "ingres";
057    
058            public static final String TYPE_INTERBASE = "interbase";
059    
060            public static final String TYPE_JDATASTORE = "jdatastore";
061    
062            public static final String TYPE_MYSQL = "mysql";
063    
064            public static final String TYPE_ORACLE = "oracle";
065    
066            public static final String TYPE_POSTGRESQL = "postgresql";
067    
068            public static final String TYPE_SAP = "sap";
069    
070            public static final String TYPE_SQLSERVER = "sqlserver";
071    
072            public static final String TYPE_SYBASE = "sybase";
073    
074            public void buildCreateFile(String sqlDir, String databaseName)
075                    throws IOException;
076    
077            public void buildCreateFile(
078                            String sqlDir, String databaseName, int population)
079                    throws IOException;
080    
081            public String buildSQL(String template) throws IOException;
082    
083            public void buildSQLFile(String sqlDir, String fileName)
084                    throws IOException;
085    
086            public List<Index> getIndexes() throws SQLException;
087    
088            public String getTemplateFalse();
089    
090            public String getTemplateTrue();
091    
092            public String getType();
093    
094            public long increment() throws SystemException;
095    
096            public long increment(String name) throws SystemException;
097    
098            public boolean isSupportsAlterColumnName();
099    
100            public boolean isSupportsAlterColumnType();
101    
102            public boolean isSupportsDateMilliseconds();
103    
104            public boolean isSupportsInlineDistinct();
105    
106            public boolean isSupportsScrollableResults();
107    
108            public boolean isSupportsStringCaseSensitiveQuery();
109    
110            public boolean isSupportsUpdateWithInnerJoin();
111    
112            public void runSQL(Connection con, String sql)
113                    throws IOException, SQLException;
114    
115            public void runSQL(Connection con, String[] sqls)
116                    throws IOException, SQLException;
117    
118            public void runSQL(String sql) throws IOException, SQLException;
119    
120            public void runSQL(String[] sqls) throws IOException, SQLException;
121    
122            public void runSQLTemplate(String path)
123                    throws IOException, NamingException, SQLException;
124    
125            public void runSQLTemplate(String path, boolean failOnError)
126                    throws IOException, NamingException, SQLException;
127    
128            public void runSQLTemplateString(
129                            String template, boolean evaluate, boolean failOnError)
130                    throws IOException, NamingException, SQLException;
131    
132            public void setSupportsStringCaseSensitiveQuery(
133                    boolean supportsStringCaseSensitiveQuery);
134    
135            public void updateIndexes(
136                            String tablesSQL, String indexesSQL, String indexesProperties,
137                            boolean dropStaleIndexes)
138                    throws IOException, SQLException;
139    
140    }