From derby-dev-return-92438-apmail-db-derby-dev-archive=db.apache.org@db.apache.org Thu Dec 22 03:41:57 2011 Return-Path: X-Original-To: apmail-db-derby-dev-archive@www.apache.org Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6429292F3 for ; Thu, 22 Dec 2011 03:41:57 +0000 (UTC) Received: (qmail 42276 invoked by uid 500); 22 Dec 2011 03:41:57 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 42257 invoked by uid 500); 22 Dec 2011 03:41:56 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 42250 invoked by uid 99); 22 Dec 2011 03:41:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Dec 2011 03:41:55 +0000 X-ASF-Spam-Status: No, hits=-2002.5 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Dec 2011 03:41:52 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id A2563122BA4 for ; Thu, 22 Dec 2011 03:41:30 +0000 (UTC) Date: Thu, 22 Dec 2011 03:41:30 +0000 (UTC) From: "Bryan Pendleton (Commented) (JIRA)" To: derby-dev@db.apache.org Message-ID: <2023608964.37990.1324525290666.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <24718480.316831290715753738.JavaMail.jira@thor> Subject: [jira] [Commented] (DERBY-4921) Statement.executeUpdate(String sql, String[] columnNames) throws ERROR X0X0F.S exception with EmbeddedDriver MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/DERBY-4921?page=3Dcom.atlassian= .jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1317= 4596#comment-13174596 ]=20 Bryan Pendleton commented on DERBY-4921: ---------------------------------------- +1 to Dag's suggestion. Is this hard? =20 > Statement.executeUpdate(String sql, String[] columnNames) throws ERROR = X0X0F.S exception with EmbeddedDriver > -------------------------------------------------------------------------= ------------------------------------- > > Key: DERBY-4921 > URL: https://issues.apache.org/jira/browse/DERBY-4921 > Project: Derby > Issue Type: Bug > Components: JDBC > Affects Versions: 10.6.2.1 > Reporter: Jarek Przyg=C3=B3dzki > > Statement.executeUpdate(insertSql, int[] columnIndexes) and Statement/exe= cuteUpdate(insertSql,Statement.RETURN_GENERATED_KEYS) does work, Statement= .executeUpdate(String sql, String[] columnNames) doesn't. > Test program > import java.sql.Connection; > import java.sql.DriverManager; > import java.sql.ResultSet; > import java.sql.Statement; > public class GetGeneratedKeysTest { > =09static String createTableSql =3D "CREATE TABLE tbl (id integer primary= key generated always as identity, name varchar(200))"; > =09static String insertSql =3D "INSERT INTO tbl(name) values('value')"; > =09static String driver =3D "org.apache.derby.jdbc.EmbeddedDriver"; > =09static String[] idColName =3D { "id" }; > =09public static void main(String[] args) throws Exception { > =09=09Class.forName(driver); > =09=09Connection conn =3D DriverManager > =09=09=09=09.getConnection("jdbc:derby:testDb;create=3Dtrue"); > =09=09conn.setAutoCommit(false); > =09=09Statement stmt =3D conn.createStatement(); > =09=09ResultSet rs; > =09=09stmt.executeUpdate(createTableSql); > =09=09stmt.executeUpdate(insertSql, idColName); > =09=09rs =3D stmt.getGeneratedKeys(); > =09=09if (rs.next()) { > =09=09=09int id =3D rs.getInt(1); > =09=09} > =09=09conn.commit(); > =09} > } > Result > Exception in thread "main" java.sql.SQLException: Table 'TBL' does not ha= ve an auto-generated column named 'id'. > =09at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQ= LExceptionFactory40.java:95) > =09at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:25= 6) > =09at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLExcepti= on(TransactionResourceImpl.java:391) > =09at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(= TransactionResourceImpl.java:346) > =09at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedCon= nection.java:2269) > =09at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Connecti= onChild.java:81) > =09at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedSta= tement.java:1321) > =09at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.ja= va:625) > =09at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(EmbedStatem= ent.java:246) > =09at GetGeneratedKeysTest.main(GetGeneratedKeysTest.java:23) > Caused by: java.sql.SQLException: Table 'TBL' does not have an auto-gener= ated column named 'id'. > =09at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLE= xceptionFactory.java:45) > =09at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTranspo= rtAcrossDRDA(SQLExceptionFactory40.java:119) > =09at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQ= LExceptionFactory40.java:70) > =09... 9 more > Caused by: ERROR X0X0F: Table 'TBL' does not have an auto-generated colum= n named 'id'. > =09at org.apache.derby.iapi.error.StandardException.newException(Standard= Exception.java:303) > =09at org.apache.derby.impl.sql.execute.InsertResultSet.verifyAutoGenerat= edColumnsNames(InsertResultSet.java:689) > =09at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResult= Set.java:419) > =09at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(Gene= ricPreparedStatement.java:436) > =09at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericP= reparedStatement.java:317) > =09at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedSta= tement.java:1232) > =09... 3 more -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrato= rs: https://issues.apache.org/jira/secure/ContactAdministrators!default.jsp= a For more information on JIRA, see: http://www.atlassian.com/software/jira