java/sql-dk/src/info/globalcode/sql/dk/SQLCommandNumbered.java
branchv_0
changeset 34 9335cf31c0f2
parent 16 5b8fcd35d4d6
child 35 b2ff3b2d58b2
equal deleted inserted replaced
33:04db6ccd6c48 34:9335cf31c0f2
    15  * You should have received a copy of the GNU General Public License
    15  * You should have received a copy of the GNU General Public License
    16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
    16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
    17  */
    17  */
    18 package info.globalcode.sql.dk;
    18 package info.globalcode.sql.dk;
    19 
    19 
       
    20 import static info.globalcode.sql.dk.Functions.notNull;
    20 import java.sql.Connection;
    21 import java.sql.Connection;
    21 import java.sql.PreparedStatement;
    22 import java.sql.PreparedStatement;
       
    23 import java.sql.SQLException;
       
    24 import java.util.List;
    22 
    25 
    23 /**
    26 /**
    24  *
    27  *
    25  * @author Ing. František Kučera (frantovo.cz)
    28  * @author Ing. František Kučera (frantovo.cz)
    26  */
    29  */
    27 public class SQLCommandNumbered extends SQLCommand {
    30 public class SQLCommandNumbered extends SQLCommand {
    28 
    31 
    29 	@Override
    32 	private List<Parameter> parameters;
    30 	public PreparedStatement prepareStatement(Connection c) {
    33 
    31 		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    34 	public SQLCommandNumbered(COMMAND_TYPE commandType, String query, List<Parameter> parameters) {
       
    35 		super(commandType, query);
       
    36 		this.parameters = parameters;
    32 	}
    37 	}
    33 
    38 
    34 	@Override
    39 	@Override
    35 	public void parametrize(PreparedStatement ps) {
    40 	public PreparedStatement prepareStatement(Connection c) throws SQLException {
    36 		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    41 		return c.prepareStatement(getQuery());
       
    42 	}
       
    43 
       
    44 	@Override
       
    45 	public void parametrize(PreparedStatement ps) throws SQLException {
       
    46 		int i = 1;
       
    47 		for (Parameter p : notNull(parameters)) {
       
    48 			ps.setObject(i++, p.getValue(), p.getType());
       
    49 		}
       
    50 	}
       
    51 
       
    52 	@Override
       
    53 	public List<Parameter> getParameters() {
       
    54 		return parameters;
    37 	}
    55 	}
    38 }
    56 }