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 getTemplateBlob();
063    
064            public String getTemplateFalse();
065    
066            public String getTemplateTrue();
067    
068            public String getVersionString();
069    
070            public long increment();
071    
072            public long increment(String name);
073    
074            public boolean isSupportsAlterColumnName();
075    
076            public boolean isSupportsAlterColumnType();
077    
078            public boolean isSupportsInlineDistinct();
079    
080            public boolean isSupportsQueryingAfterException();
081    
082            public boolean isSupportsScrollableResults();
083    
084            public boolean isSupportsStringCaseSensitiveQuery();
085    
086            public boolean isSupportsUpdateWithInnerJoin();
087    
088            public void runSQL(Connection con, String sql)
089                    throws IOException, SQLException;
090    
091            public void runSQL(Connection con, String[] sqls)
092                    throws IOException, SQLException;
093    
094            public void runSQL(String sql) throws IOException, SQLException;
095    
096            public void runSQL(String[] sqls) throws IOException, SQLException;
097    
098            public void runSQLTemplate(String path)
099                    throws IOException, NamingException, SQLException;
100    
101            public void runSQLTemplate(String path, boolean failOnError)
102                    throws IOException, NamingException, SQLException;
103    
104            public void runSQLTemplateString(
105                            Connection connection, String template, boolean evaluate,
106                            boolean failOnError)
107                    throws IOException, NamingException, SQLException;
108    
109            public void runSQLTemplateString(
110                            String template, boolean evaluate, boolean failOnError)
111                    throws IOException, NamingException, SQLException;
112    
113            public void setSupportsStringCaseSensitiveQuery(
114                    boolean supportsStringCaseSensitiveQuery);
115    
116            public void updateIndexes(
117                            Connection con, String tablesSQL, String indexesSQL,
118                            boolean dropStaleIndexes)
119                    throws IOException, SQLException;
120    
121    }