001/* 002 * HA-JDBC: High-Availability JDBC 003 * Copyright (C) 2012 Paul Ferraro 004 * 005 * This program is free software: you can redistribute it and/or modify 006 * it under the terms of the GNU Lesser General Public License as published by 007 * the Free Software Foundation, either version 3 of the License, or 008 * (at your option) any later version. 009 * 010 * This program is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public License 016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 017 */ 018package net.sf.hajdbc; 019 020import java.sql.DatabaseMetaData; 021import java.sql.SQLException; 022import java.util.Collection; 023 024/** 025 * @author Paul Ferraro 026 */ 027public interface SequenceSupport 028{ 029 /** 030 * Parses a sequence name from the specified SQL statement. 031 * @param sql a SQL statement 032 * @return the name of a sequence, or null if this SQL statement does not reference a sequence or this dialect does not support sequences 033 * @throws SQLException 034 * @since 2.0 035 */ 036 String parseSequence(String sql) throws SQLException; 037 038 /** 039 * Returns a collection of sequences using dialect specific logic. 040 * @param metaData database meta data 041 * @return a collection of sequences 042 * @throws SQLException 043 */ 044 Collection<SequenceProperties> getSequences(DatabaseMetaData metaData, SequencePropertiesFactory factory) throws SQLException; 045 046 /** 047 * Returns a SQL statement for obtaining the next value the specified sequence 048 * @param sequence a sequence name 049 * @return a SQL statement 050 * @throws SQLException 051 * @since 2.0 052 */ 053 String getNextSequenceValueSQL(SequenceProperties sequence) throws SQLException; 054 055 /** 056 * Returns a SQL statement used reset the current value of a sequence. 057 * @param sequence a sequence name 058 * @param value a sequence value 059 * @return a SQL statement 060 * @throws SQLException 061 * @since 2.0 062 */ 063 String getAlterSequenceSQL(SequenceProperties sequence, long value) throws SQLException; 064 065 SequencePropertiesFactory createSequencePropertiesFactory(QualifiedNameFactory factory); 066}