Revision 43093 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCSQLBuilderBase.java
JDBCSQLBuilderBase.java | ||
---|---|---|
1 |
|
|
2 | 1 |
package org.gvsig.fmap.dal.store.jdbc2.spi; |
3 | 2 |
|
4 | 3 |
import java.sql.PreparedStatement; |
5 | 4 |
import java.util.ArrayList; |
6 | 5 |
import java.util.List; |
6 |
import org.gvsig.fmap.dal.feature.spi.SQLBuilderBase; |
|
7 | 7 |
import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
8 |
import org.gvsig.fmap.dal.feature.spi.SQLBuilderBase; |
|
9 | 8 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils; |
10 | 9 |
|
11 |
|
|
12 | 10 |
public class JDBCSQLBuilderBase extends SQLBuilderBase { |
13 | 11 |
|
14 | 12 |
public JDBCSQLBuilderBase() { |
15 | 13 |
super(); |
16 | 14 |
} |
17 | 15 |
|
16 |
public void setParameters(PreparedStatement st) { |
|
17 |
try { |
|
18 |
int columnIndex = 1; |
|
19 |
for (Parameter parameter : this.getParameters()) { |
|
20 |
st.setObject(columnIndex++, parameter.getValue()); |
|
21 |
} |
|
22 |
} catch (Exception ex) { |
|
23 |
String p = "unknow"; |
|
24 |
try { |
|
25 |
p = this.getParameters().toString(); |
|
26 |
} catch (Exception ex2) { |
|
27 |
// Do nothing |
|
28 |
} |
|
29 |
throw new RuntimeException("Can't set parameters to prepared statement from parameters (" + p + ")", ex); |
|
30 |
} |
|
31 |
} |
|
32 |
|
|
18 | 33 |
public void setParameters(PreparedStatement st, FeatureProvider feature) { |
19 | 34 |
try { |
20 |
|
|
21 | 35 |
List<Object> values = new ArrayList<>(); |
22 | 36 |
for (Parameter parameter : this.getParameters()) { |
23 |
if( parameter.is_constant() ) {
|
|
37 |
if (parameter.is_constant()) {
|
|
24 | 38 |
values.add(parameter.getValue()); |
25 | 39 |
} else { |
26 | 40 |
String name = parameter.getName(); |
... | ... | |
29 | 43 |
} |
30 | 44 |
JDBCUtils.setObjects(st, values, this.geometry_support_type()); |
31 | 45 |
} catch (Exception ex) { |
32 |
throw new RuntimeException("Can't set parameters to prepared statement", ex); |
|
46 |
String f = "unknow"; |
|
47 |
try { |
|
48 |
f = feature.toString(); |
|
49 |
} catch (Exception ex2) { |
|
50 |
// Do nothing |
|
51 |
} |
|
52 |
throw new RuntimeException("Can't set parameters to prepared statement from the feature (" + f + ")", ex); |
|
33 | 53 |
} |
34 | 54 |
} |
35 | 55 |
|
36 | 56 |
} |
37 |
|
Also available in: Unified diff