franta-hg@16: /** franta-hg@16: * SQL-DK franta-hg@16: * Copyright © 2013 František Kučera (frantovo.cz) franta-hg@16: * franta-hg@16: * This program is free software: you can redistribute it and/or modify franta-hg@16: * it under the terms of the GNU General Public License as published by franta-hg@16: * the Free Software Foundation, either version 3 of the License, or franta-hg@16: * (at your option) any later version. franta-hg@16: * franta-hg@16: * This program is distributed in the hope that it will be useful, franta-hg@16: * but WITHOUT ANY WARRANTY; without even the implied warranty of franta-hg@16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the franta-hg@16: * GNU General Public License for more details. franta-hg@16: * franta-hg@16: * You should have received a copy of the GNU General Public License franta-hg@16: * along with this program. If not, see . franta-hg@16: */ franta-hg@1: package info.globalcode.sql.dk; franta-hg@1: franta-hg@1: import java.sql.Connection; franta-hg@1: import java.sql.PreparedStatement; franta-hg@34: import java.sql.SQLException; franta-hg@34: import java.util.List; franta-hg@1: franta-hg@1: /** franta-hg@1: * franta-hg@1: * @author Ing. František Kučera (frantovo.cz) franta-hg@1: */ franta-hg@1: public abstract class SQLCommand { franta-hg@1: franta-hg@29: private COMMAND_TYPE commandType; franta-hg@1: private String query; franta-hg@1: franta-hg@34: public SQLCommand(COMMAND_TYPE commandType, String query) { franta-hg@34: this.commandType = commandType; franta-hg@34: this.query = query; franta-hg@34: } franta-hg@1: franta-hg@35: public PreparedStatement prepareStatement(Connection c) throws SQLException { franta-hg@35: return c.prepareStatement(query); franta-hg@35: } franta-hg@34: franta-hg@34: public abstract void parametrize(PreparedStatement ps) throws SQLException; franta-hg@34: franta-hg@34: public abstract List getParameters(); franta-hg@29: franta-hg@29: public COMMAND_TYPE getCommandType() { franta-hg@29: return commandType; franta-hg@29: } franta-hg@29: franta-hg@29: public void setCommandType(COMMAND_TYPE commandType) { franta-hg@29: this.commandType = commandType; franta-hg@29: } franta-hg@29: franta-hg@29: public String getQuery() { franta-hg@29: return query; franta-hg@29: } franta-hg@29: franta-hg@29: public enum COMMAND_TYPE { franta-hg@29: franta-hg@29: /** SELECT */ franta-hg@29: QUERY, franta-hg@29: /** INSERT, UPDATE, DELETE */ franta-hg@29: UPDATE franta-hg@29: }; franta-hg@1: }