001    /**
002     * Copyright (c) 2000-present 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 aQute.bnd.annotation.ProviderType;
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    @ProviderType
033    public interface DB {
034    
035            public static final int BARE = 0;
036    
037            public static final int DEFAULT = 1;
038    
039            public void addIndexes(
040                            Connection con, String indexesSQL, Set<String> validIndexNames)
041                    throws IOException;
042    
043            public void buildCreateFile(String sqlDir, String databaseName)
044                    throws IOException;
045    
046            public void buildCreateFile(
047                            String sqlDir, String databaseName, int population)
048                    throws IOException;
049    
050            public String buildSQL(String template) throws IOException;
051    
052            public void buildSQLFile(String sqlDir, String fileName) throws IOException;
053    
054            public DBType getDBType();
055    
056            public List<Index> getIndexes(Connection con) throws SQLException;
057    
058            public int getMajorVersion();
059    
060            public int getMinorVersion();
061    
062            public String getTemplateFalse();
063    
064            public String getTemplateTrue();
065    
066            public String getVersionString();
067    
068            public long increment();
069    
070            public long increment(String name);
071    
072            public boolean isSupportsAlterColumnName();
073    
074            public boolean isSupportsAlterColumnType();
075    
076            public boolean isSupportsInlineDistinct();
077    
078            public boolean isSupportsQueryingAfterException();
079    
080            public boolean isSupportsScrollableResults();
081    
082            public boolean isSupportsStringCaseSensitiveQuery();
083    
084            public boolean isSupportsUpdateWithInnerJoin();
085    
086            public void runSQL(Connection con, String sql)
087                    throws IOException, SQLException;
088    
089            public void runSQL(Connection con, String[] sqls)
090                    throws IOException, SQLException;
091    
092            public void runSQL(String sql) throws IOException, SQLException;
093    
094            public void runSQL(String[] sqls) throws IOException, SQLException;
095    
096            public void runSQLTemplate(String path)
097                    throws IOException, NamingException, SQLException;
098    
099            public void runSQLTemplate(String path, boolean failOnError)
100                    throws IOException, NamingException, SQLException;
101    
102            public void runSQLTemplateString(
103                            Connection connection, String template, boolean evaluate,
104                            boolean failOnError)
105                    throws IOException, NamingException, SQLException;
106    
107            public void runSQLTemplateString(
108                            String template, boolean evaluate, boolean failOnError)
109                    throws IOException, NamingException, SQLException;
110    
111            public void setSupportsStringCaseSensitiveQuery(
112                    boolean supportsStringCaseSensitiveQuery);
113    
114            public void updateIndexes(
115                            Connection con, String tablesSQL, String indexesSQL,
116                            boolean dropStaleIndexes)
117                    throws IOException, SQLException;
118    
119    }