Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 0C787200C79 for ; Fri, 5 May 2017 05:52:10 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0B2EE160BC4; Fri, 5 May 2017 03:52:10 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 51230160BB0 for ; Fri, 5 May 2017 05:52:09 +0200 (CEST) Received: (qmail 21333 invoked by uid 500); 5 May 2017 03:52:08 -0000 Mailing-List: contact notifications-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list notifications@groovy.apache.org Received: (qmail 21323 invoked by uid 99); 5 May 2017 03:52:08 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 May 2017 03:52:08 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id F2FC81A5F26 for ; Fri, 5 May 2017 03:52:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id NA5DRWoH4Teq for ; Fri, 5 May 2017 03:52:07 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id C31C85FB48 for ; Fri, 5 May 2017 03:52:06 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 21810E099E for ; Fri, 5 May 2017 03:52:06 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 0595021DED for ; Fri, 5 May 2017 03:52:05 +0000 (UTC) Date: Fri, 5 May 2017 03:52:05 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: notifications@groovy.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (GROOVY-8174) Groovy.Sql+Oracle parameter substitution problem MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 05 May 2017 03:52:10 -0000 [ https://issues.apache.org/jira/browse/GROOVY-8174?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15997764#comment-15997764 ] ASF GitHub Bot commented on GROOVY-8174: ---------------------------------------- Github user asfgit closed the pull request at: https://github.com/apache/groovy/pull/534 > Groovy.Sql+Oracle parameter substitution problem > ------------------------------------------------ > > Key: GROOVY-8174 > URL: https://issues.apache.org/jira/browse/GROOVY-8174 > Project: Groovy > Issue Type: Bug > Components: SQL processing > Affects Versions: 2.4.11 > Environment: Java 1.8.0_131, Groovy 2.4.11, Oracle ojdbc7 12.1.0.2.0 > Reporter: Thom DeCarlo > > I'm using the groovy.sql libraries inside of a Java program and having trouble with parameter substitution. My code looks like this: > {code} > def mdds = Sql.newInstance(...) > Mapparams = new HashMap(); > params.clear(); > params.put("source_system_id", Integer.valueOf(6)); > params.put("rec_loc_txt", "Test" + randomNum.toString()); > params.put("created_dt_tm", new Timestamp(System.currentTimeMillis())); > > String mdSqlString = "INSERT INTO MD_CATALOG " + > " (SOURCE_SYSTEM_ID, REC_LOC_TXT, CREATED_DT_TM)" + > " VALUES" + > " (:source_system_id, :rec_loc_txt, :created_dt_tm)"; > try { > List> keys = mdds.executeInsert(params, mdSqlString); > } catch (SQLException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > {code} > But, when it runs, I get an exception thrown that says: > {code} > Exception in thread "main" java.lang.IllegalArgumentException: Found 4 parameter placeholders but supplied with 3 parameters > at groovy.sql.Sql.setParameters(Sql.java:4116) > at groovy.sql.Sql.getPreparedStatement(Sql.java:4394) > at groovy.sql.Sql.executeInsert(Sql.java:2610) > at groovy.sql.Sql.executeInsert(Sql.java:2674) > at org.mitre.mac.Main.main(Main.java:70) > {code} > But, I only see 3 placeholders for my 3 parameters. > Via email, John Wagenleitner replied: > I did a quick test with Groovy 2.4.11 and Oracle 11.2.0.4 (ojdbc6.jar 11.2.0.4 and ojdbc7.jar 12.1.0.2.0) and get the same error. From what I am seeing Oracle changes the sql to: > {code}INSERT INTO MD_CATALOG (SOURCE_SYSTEM_ID, REC_LOC_TXT, CREATED_DT_TM) VALUES (?, ?, ?) RETURNING ROWID INTO ?{code} > adding the extra bind parameter for ROWID and this is reflected in the call to [metaData.getParameterCount()|https://github.com/apache/groovy/blob/GROOVY_2_4_11/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java#L4115] -- This message was sent by Atlassian JIRA (v6.3.15#6346)