Skip to content

Commit 4efd3f9

Browse files
committed
Add changes to Select Action: setStatementParam if Statement has it
1 parent 396591d commit 4efd3f9

File tree

1 file changed

+5
-3
lines changed
  • src/main/java/io/elastic/jdbc/QueryBuilders

1 file changed

+5
-3
lines changed

src/main/java/io/elastic/jdbc/QueryBuilders/Query.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,11 @@ public ArrayList executeSelectQuery(Connection connection, String sqlQuery, Json
132132
throws SQLException {
133133
try (PreparedStatement stmt = connection.prepareStatement(sqlQuery)) {
134134
int i = 1;
135-
for (Entry<String, JsonValue> entry : body.entrySet()) {
136-
Utils.setStatementParam(stmt, i, entry.getKey(), body);
137-
i++;
135+
if (stmt.getParameterMetaData().getParameterCount() != 0) {
136+
for (Entry<String, JsonValue> entry : body.entrySet()) {
137+
Utils.setStatementParam(stmt, i, entry.getKey(), body);
138+
i++;
139+
}
138140
}
139141
try (ResultSet rs = stmt.executeQuery()) {
140142
JsonObjectBuilder row = Json.createObjectBuilder();

0 commit comments

Comments
 (0)