author | František Kučera <franta-hg@frantovo.cz> |
Wed, 15 Jan 2014 22:22:45 +0100 | |
branch | v_0 |
changeset 163 | 1df10a9be6f4 |
parent 155 | eb3676c6929b |
permissions | -rw-r--r-- |
franta-hg@16 | 1 |
/** |
franta-hg@16 | 2 |
* SQL-DK |
franta-hg@16 | 3 |
* Copyright © 2013 František Kučera (frantovo.cz) |
franta-hg@16 | 4 |
* |
franta-hg@16 | 5 |
* This program is free software: you can redistribute it and/or modify |
franta-hg@16 | 6 |
* it under the terms of the GNU General Public License as published by |
franta-hg@16 | 7 |
* the Free Software Foundation, either version 3 of the License, or |
franta-hg@16 | 8 |
* (at your option) any later version. |
franta-hg@16 | 9 |
* |
franta-hg@16 | 10 |
* This program is distributed in the hope that it will be useful, |
franta-hg@16 | 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
franta-hg@16 | 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
franta-hg@16 | 13 |
* GNU General Public License for more details. |
franta-hg@16 | 14 |
* |
franta-hg@16 | 15 |
* You should have received a copy of the GNU General Public License |
franta-hg@16 | 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
franta-hg@16 | 17 |
*/ |
franta-hg@1 | 18 |
package info.globalcode.sql.dk; |
franta-hg@1 | 19 |
|
franta-hg@34 | 20 |
import static info.globalcode.sql.dk.Functions.notNull; |
franta-hg@1 | 21 |
import java.sql.PreparedStatement; |
franta-hg@34 | 22 |
import java.sql.SQLException; |
franta-hg@34 | 23 |
import java.util.List; |
franta-hg@1 | 24 |
|
franta-hg@1 | 25 |
/** |
franta-hg@155 | 26 |
* Has ordinal/numbered parameters. |
franta-hg@1 | 27 |
* |
franta-hg@1 | 28 |
* @author Ing. František Kučera (frantovo.cz) |
franta-hg@1 | 29 |
*/ |
franta-hg@1 | 30 |
public class SQLCommandNumbered extends SQLCommand { |
franta-hg@1 | 31 |
|
franta-hg@143 | 32 |
private List<? extends Parameter> parameters; |
franta-hg@34 | 33 |
|
franta-hg@143 | 34 |
public SQLCommandNumbered(String query, List<? extends Parameter> parameters) { |
franta-hg@37 | 35 |
super(query); |
franta-hg@34 | 36 |
this.parameters = parameters; |
franta-hg@1 | 37 |
} |
franta-hg@1 | 38 |
|
franta-hg@1 | 39 |
@Override |
franta-hg@34 | 40 |
public void parametrize(PreparedStatement ps) throws SQLException { |
franta-hg@34 | 41 |
int i = 1; |
franta-hg@34 | 42 |
for (Parameter p : notNull(parameters)) { |
franta-hg@68 | 43 |
ps.setObject(i++, p.getValue(), p.getType().getCode()); |
franta-hg@34 | 44 |
} |
franta-hg@34 | 45 |
} |
franta-hg@34 | 46 |
|
franta-hg@34 | 47 |
@Override |
franta-hg@143 | 48 |
public List<? extends Parameter> getParameters() { |
franta-hg@34 | 49 |
return parameters; |
franta-hg@1 | 50 |
} |
franta-hg@1 | 51 |
} |