Return-Path: X-Original-To: apmail-db-derby-user-archive@www.apache.org Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 57A1710471 for ; Mon, 29 Apr 2013 14:22:17 +0000 (UTC) Received: (qmail 59188 invoked by uid 500); 29 Apr 2013 14:22:16 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 59168 invoked by uid 500); 29 Apr 2013 14:22:16 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 59152 invoked by uid 99); 29 Apr 2013 14:22:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Apr 2013 14:22:16 +0000 X-ASF-Spam-Status: No, hits=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS,UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of knut.hatlen@oracle.com designates 156.151.31.81 as permitted sender) Received: from [156.151.31.81] (HELO userp1040.oracle.com) (156.151.31.81) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Apr 2013 14:22:08 +0000 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r3TELjgj002052 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 29 Apr 2013 14:21:45 GMT Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r3TELjE9023255 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Mon, 29 Apr 2013 14:21:45 GMT Received: from abhmt118.oracle.com (abhmt118.oracle.com [141.146.116.70]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r3TELjop023249 for ; Mon, 29 Apr 2013 14:21:45 GMT Received: from localhost (/10.172.139.141) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 29 Apr 2013 07:21:44 -0700 From: Knut Anders Hatlen To: "Derby Discussion" Subject: Re: CallableStatement: SYSCS_(S/G)ET_DATABASE_PROPERTY behaviours References: Mail-Copies-To: never Mail-Followup-To: "Derby Discussion" Date: Mon, 29 Apr 2013 16:21:42 +0200 In-Reply-To: (Guillaume CHAUVET's message of "Mon, 29 Apr 2013 13:45:03 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Source-IP: acsinet21.oracle.com [141.146.126.237] X-Virus-Checked: Checked by ClamAV on apache.org Guillaume CHAUVET writes: > Hello Derby users ! > > I encountered some difficulties with Derby and CallableStatement. In my c= ase, I try to save a custom property into DB Derby properties (A database i= nternal version number). > > To do that, I use SYSCS_SET_DATABASE_PROPERTY and SYSCS_GET_DATABASE_PROP= ERTY functions. > > Below, the SQL requests successfully executed from the default Netbeans S= QL plugin : > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D > > CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('softrev', '1.0.0'); > >>Executed successfully in 0,001 s, 0 rows affected. > >>Line 1, column 1 > > VALUES SYSCS_UTIL.SYSCS_GET_DATABASE_PROPERTY('softrev'); > >>Executed successfully in 0 s. > >>Line 2, column 1 > >>1# =E2=80=981.0.0=E2=80=99 (the expected result). > > Now, I tried to do the same thing in Java (see the attached unitary test)= , but nothing happens as expected=E2=80=A6 > > Attached, please find a maven draft with a unitary test that reproduce th= e unexpected behaviour. Hi Guillaume, It looks like your Java program used CALL for calling the SYSCS_GET_DATABASE_PROPERTY function, whereas you used VALUES in the NetBeans SQL plugin. Derby doesn't support calling functions with a CALL statement, so I believe your test case needs to be changed to something like this (untested code): @Test public void testRetrieveVersionProperty() throws Exception { PreparedStatement ps =3D con.prepareStatement("VALUES SYSCS_UTIL.SY= SCS_GET_DATABASE_PROPERTY(?)"); try { ps.setString(1, VERSION_OPT); ResultSet rs =3D ps.executeQuery(); try { assertTrue(rs.next()); assertEquals(EXPECTED_VERSION, rs.getString(1)); } finally { rs.close(); } } finally { ps.close(); } } Hope this helps, --=20 Knut Anders