Skip to content

Commit dfbfab0

Browse files
author
Claudio Gomes da Silva
committed
Merge remote-tracking branch 'origin/master'
2 parents f16e266 + 8a6e397 commit dfbfab0

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.github.clagomess</groupId>
88
<artifactId>mod-plsql</artifactId>
9-
<version>1.0.1</version>
9+
<version>1.0.2</version>
1010

1111
<properties>
1212
<jetty.version>9.4.19.v20190610</jetty.version>

src/main/java/com/github/clagomess/modplsql/jdbc/Database.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public static void init(ConfigDto dto) throws SQLException {
3232
}
3333

3434
public static String runPl(String plName, Map<String, String> param) throws SQLException {
35+
int idx;
36+
3537
// fill parans
3638
param.putAll(configDto.getParamsAsMap());
3739

@@ -45,10 +47,10 @@ public static String runPl(String plName, Map<String, String> param) throws SQLE
4547

4648
sql.append(String.format(" NUM_ENTRIES := %s;\n", param.size()));
4749

48-
int idx = 1;
50+
idx = 1;
4951
for (Map.Entry<String, String> entry : param.entrySet()) {
50-
sql.append(String.format(" NAME_ARRAY(%s) := '%s';\n", idx, entry.getKey()));
51-
sql.append(String.format(" VALUE_ARRAY(%s) := '%s';\n", idx, escape(entry.getValue())));
52+
sql.append(String.format(" NAME_ARRAY(%s) := ?; -- '%s'\n", idx, entry.getKey()));
53+
sql.append(String.format(" VALUE_ARRAY(%s) := ?; -- '%s'\n", idx, escape(entry.getValue())));
5254
idx++;
5355
}
5456

@@ -63,9 +65,17 @@ public static String runPl(String plName, Map<String, String> param) throws SQLE
6365

6466
log.info("QUERY:\n{}", sql.toString());
6567

66-
stmt.executeUpdate(sql.toString());
68+
PreparedStatement pstmt = conn.prepareStatement(sql.toString());
69+
idx = 1;
70+
for (Map.Entry<String, String> entry : param.entrySet()) {
71+
pstmt.setString(idx, entry.getKey());
72+
idx++;
73+
pstmt.setString(idx, entry.getValue());
74+
idx++;
75+
}
76+
77+
pstmt.execute();
6778

68-
log.info("GET RESULT");
6979
return getResult();
7080
}
7181

0 commit comments

Comments
 (0)