[jira] [Commented] (DERBY-4921) Statement.executeUpdate(String sql, String[] columnNames) throws ERROR X0X0F.S exception with EmbeddedDriver
[ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13570302#comment-13570302 ] Philip Ogren commented on DERBY-4921: - If you change the client driver to behave as the embedded driver as you suggest above, then it will not be possible for my example code to work with both the Derby driver and the PostgreSQL driver without adding a driver-specific conditional. Please note Knut's observation about PostgreSQL above. It would be much preferable to me to see the embedded driver behave like the client driver because that will be much less likely break other people's code (including mine.) 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ódzki Statement.executeUpdate(insertSql, int[] columnIndexes) and Statement/executeUpdate(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 { static String createTableSql = CREATE TABLE tbl (id integer primary key generated always as identity, name varchar(200)); static String insertSql = INSERT INTO tbl(name) values('value'); static String driver = org.apache.derby.jdbc.EmbeddedDriver; static String[] idColName = { id }; public static void main(String[] args) throws Exception { Class.forName(driver); Connection conn = DriverManager .getConnection(jdbc:derby:testDb;create=true); conn.setAutoCommit(false); Statement stmt = conn.createStatement(); ResultSet rs; stmt.executeUpdate(createTableSql); stmt.executeUpdate(insertSql, idColName); rs = stmt.getGeneratedKeys(); if (rs.next()) { int id = rs.getInt(1); } conn.commit(); } } Result Exception in thread main java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:95) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:256) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:391) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2269) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1321) at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:625) at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(EmbedStatement.java:246) at GetGeneratedKeysTest.main(GetGeneratedKeysTest.java:23) Caused by: java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:119) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:70) ... 9 more Caused by: ERROR X0X0F: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:303) at org.apache.derby.impl.sql.execute.InsertResultSet.verifyAutoGeneratedColumnsNames(InsertResultSet.java:689) at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:419) at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:436) at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:317) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1232) ... 3 more -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see:
[jira] [Commented] (DERBY-4921) Statement.executeUpdate(String sql, String[] columnNames) throws ERROR X0X0F.S exception with EmbeddedDriver
[ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13569715#comment-13569715 ] Dag H. Wanvik commented on DERBY-4921: -- We should probably file a new issue to fix the client driver here (or rename this issue); I agree it is not good that the drivers behave differently. It seems the driver doesn't do any checking on the column identifier here; the code example provided by Philip for the client works with arbitrary column names: e.g. connection.prepareStatement(INSERT_SQL, new String[] {foo}) 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ódzki Statement.executeUpdate(insertSql, int[] columnIndexes) and Statement/executeUpdate(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 { static String createTableSql = CREATE TABLE tbl (id integer primary key generated always as identity, name varchar(200)); static String insertSql = INSERT INTO tbl(name) values('value'); static String driver = org.apache.derby.jdbc.EmbeddedDriver; static String[] idColName = { id }; public static void main(String[] args) throws Exception { Class.forName(driver); Connection conn = DriverManager .getConnection(jdbc:derby:testDb;create=true); conn.setAutoCommit(false); Statement stmt = conn.createStatement(); ResultSet rs; stmt.executeUpdate(createTableSql); stmt.executeUpdate(insertSql, idColName); rs = stmt.getGeneratedKeys(); if (rs.next()) { int id = rs.getInt(1); } conn.commit(); } } Result Exception in thread main java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:95) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:256) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:391) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2269) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1321) at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:625) at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(EmbedStatement.java:246) at GetGeneratedKeysTest.main(GetGeneratedKeysTest.java:23) Caused by: java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:119) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:70) ... 9 more Caused by: ERROR X0X0F: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:303) at org.apache.derby.impl.sql.execute.InsertResultSet.verifyAutoGeneratedColumnsNames(InsertResultSet.java:689) at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:419) at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:436) at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:317) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1232) ... 3 more -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (DERBY-4921) Statement.executeUpdate(String sql, String[] columnNames) throws ERROR X0X0F.S exception with EmbeddedDriver
[ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13569723#comment-13569723 ] Dag H. Wanvik commented on DERBY-4921: -- Linking to DERBY-4015. 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ódzki Statement.executeUpdate(insertSql, int[] columnIndexes) and Statement/executeUpdate(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 { static String createTableSql = CREATE TABLE tbl (id integer primary key generated always as identity, name varchar(200)); static String insertSql = INSERT INTO tbl(name) values('value'); static String driver = org.apache.derby.jdbc.EmbeddedDriver; static String[] idColName = { id }; public static void main(String[] args) throws Exception { Class.forName(driver); Connection conn = DriverManager .getConnection(jdbc:derby:testDb;create=true); conn.setAutoCommit(false); Statement stmt = conn.createStatement(); ResultSet rs; stmt.executeUpdate(createTableSql); stmt.executeUpdate(insertSql, idColName); rs = stmt.getGeneratedKeys(); if (rs.next()) { int id = rs.getInt(1); } conn.commit(); } } Result Exception in thread main java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:95) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:256) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:391) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2269) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1321) at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:625) at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(EmbedStatement.java:246) at GetGeneratedKeysTest.main(GetGeneratedKeysTest.java:23) Caused by: java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:119) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:70) ... 9 more Caused by: ERROR X0X0F: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:303) at org.apache.derby.impl.sql.execute.InsertResultSet.verifyAutoGeneratedColumnsNames(InsertResultSet.java:689) at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:419) at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:436) at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:317) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1232) ... 3 more -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (DERBY-4921) Statement.executeUpdate(String sql, String[] columnNames) throws ERROR X0X0F.S exception with EmbeddedDriver
[ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13569724#comment-13569724 ] Dag H. Wanvik commented on DERBY-4921: -- Quote from DERBY-2653: The driver will ignore the array if the SQL statement is not an INSERT statement, or an SQL statement able to return auto-generated keys (the list of such statements is vendor-specific). https://issues.apache.org/jira/browse/DERBY-2653?focusedCommentId=12569412page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12569412 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ódzki Statement.executeUpdate(insertSql, int[] columnIndexes) and Statement/executeUpdate(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 { static String createTableSql = CREATE TABLE tbl (id integer primary key generated always as identity, name varchar(200)); static String insertSql = INSERT INTO tbl(name) values('value'); static String driver = org.apache.derby.jdbc.EmbeddedDriver; static String[] idColName = { id }; public static void main(String[] args) throws Exception { Class.forName(driver); Connection conn = DriverManager .getConnection(jdbc:derby:testDb;create=true); conn.setAutoCommit(false); Statement stmt = conn.createStatement(); ResultSet rs; stmt.executeUpdate(createTableSql); stmt.executeUpdate(insertSql, idColName); rs = stmt.getGeneratedKeys(); if (rs.next()) { int id = rs.getInt(1); } conn.commit(); } } Result Exception in thread main java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:95) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:256) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:391) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2269) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1321) at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:625) at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(EmbedStatement.java:246) at GetGeneratedKeysTest.main(GetGeneratedKeysTest.java:23) Caused by: java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:119) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:70) ... 9 more Caused by: ERROR X0X0F: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:303) at org.apache.derby.impl.sql.execute.InsertResultSet.verifyAutoGeneratedColumnsNames(InsertResultSet.java:689) at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:419) at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:436) at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:317) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1232) ... 3 more -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (DERBY-4921) Statement.executeUpdate(String sql, String[] columnNames) throws ERROR X0X0F.S exception with EmbeddedDriver
[ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13569726#comment-13569726 ] Dag H. Wanvik commented on DERBY-4921: -- DERBY-2653 contains a discussion of the difference in behavior between the client and embedded drivers here, so linking. 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ódzki Statement.executeUpdate(insertSql, int[] columnIndexes) and Statement/executeUpdate(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 { static String createTableSql = CREATE TABLE tbl (id integer primary key generated always as identity, name varchar(200)); static String insertSql = INSERT INTO tbl(name) values('value'); static String driver = org.apache.derby.jdbc.EmbeddedDriver; static String[] idColName = { id }; public static void main(String[] args) throws Exception { Class.forName(driver); Connection conn = DriverManager .getConnection(jdbc:derby:testDb;create=true); conn.setAutoCommit(false); Statement stmt = conn.createStatement(); ResultSet rs; stmt.executeUpdate(createTableSql); stmt.executeUpdate(insertSql, idColName); rs = stmt.getGeneratedKeys(); if (rs.next()) { int id = rs.getInt(1); } conn.commit(); } } Result Exception in thread main java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:95) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:256) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:391) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2269) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1321) at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:625) at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(EmbedStatement.java:246) at GetGeneratedKeysTest.main(GetGeneratedKeysTest.java:23) Caused by: java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:119) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:70) ... 9 more Caused by: ERROR X0X0F: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:303) at org.apache.derby.impl.sql.execute.InsertResultSet.verifyAutoGeneratedColumnsNames(InsertResultSet.java:689) at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:419) at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:436) at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:317) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1232) ... 3 more -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (DERBY-4921) Statement.executeUpdate(String sql, String[] columnNames) throws ERROR X0X0F.S exception with EmbeddedDriver
[ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13569193#comment-13569193 ] Philip Ogren commented on DERBY-4921: - I would like to challenge the decision to close this issue. I was really confused about why I was seeing this behavior today even after finding and reading through this issue because I had never seen it before. I finally realized that it was because the behavior between the EmbeddedDriver and ClientDriver differs on this exact point and I had always used the client driver on my code in question. I think it is one thing to throw up your hands because the spec is vague (and even still, it seems obvious to me that this is a bug) but I think it is not really defensible to have the two drivers behave differently. Please reopen and fix! 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ódzki Statement.executeUpdate(insertSql, int[] columnIndexes) and Statement/executeUpdate(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 { static String createTableSql = CREATE TABLE tbl (id integer primary key generated always as identity, name varchar(200)); static String insertSql = INSERT INTO tbl(name) values('value'); static String driver = org.apache.derby.jdbc.EmbeddedDriver; static String[] idColName = { id }; public static void main(String[] args) throws Exception { Class.forName(driver); Connection conn = DriverManager .getConnection(jdbc:derby:testDb;create=true); conn.setAutoCommit(false); Statement stmt = conn.createStatement(); ResultSet rs; stmt.executeUpdate(createTableSql); stmt.executeUpdate(insertSql, idColName); rs = stmt.getGeneratedKeys(); if (rs.next()) { int id = rs.getInt(1); } conn.commit(); } } Result Exception in thread main java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:95) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:256) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:391) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2269) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1321) at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:625) at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(EmbedStatement.java:246) at GetGeneratedKeysTest.main(GetGeneratedKeysTest.java:23) Caused by: java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:119) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:70) ... 9 more Caused by: ERROR X0X0F: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:303) at org.apache.derby.impl.sql.execute.InsertResultSet.verifyAutoGeneratedColumnsNames(InsertResultSet.java:689) at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:419) at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:436) at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:317) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1232) ... 3
[jira] [Commented] (DERBY-4921) Statement.executeUpdate(String sql, String[] columnNames) throws ERROR X0X0F.S exception with EmbeddedDriver
[ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13569197#comment-13569197 ] Philip Ogren commented on DERBY-4921: - I prepared some code that demonstrates the behavior that I ran on the latest driver (10.9.1.0). I don't see away to attach it so I will just paste it here. Hopefully, it will render ok. import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; /** * to run testClientDriver first start the Derby server with something like: * java -jar derbyrun.jar server start * * to run testEmbeddedDriver change the local variable 'location' to some directory that exists on your system. */ public class DerbyTest { public static final String CREATE_TABLE_SQL = create table test_table (id int generated always as identity primary key, name varchar(100)); public static final String INSERT_SQL = insert into test_table (name) values (?); public static void testClientDriver() throws Exception { String driver = org.apache.derby.jdbc.ClientDriver; Class.forName(driver).newInstance(); Connection connection = DriverManager.getConnection(jdbc:derby://localhost:1527/testdb;create=true); connection.prepareStatement(drop table test_table).execute(); connection.prepareStatement(CREATE_TABLE_SQL).execute(); for(String columnName : new String[] {ID, id}) { PreparedStatement statement = connection.prepareStatement(INSERT_SQL, new String[] { columnName}); statement.setString(1, my name); statement.executeUpdate(); ResultSet results = statement.getGeneratedKeys(); results.next(); int id = results.getInt(1); System.out.println(id); } } public static void testEmbeddedDriver() throws Exception { String driver = org.apache.derby.jdbc.EmbeddedDriver; Class.forName(driver).newInstance(); String location = D:\\temp; Connection connection = DriverManager.getConnection(jdbc:derby:+location+\\testdb;create=true); connection.prepareStatement(drop table test_table).execute(); connection.prepareStatement(CREATE_TABLE_SQL).execute(); for(String columnName : new String[] {ID, id}) { PreparedStatement statement = connection.prepareStatement(INSERT_SQL, new String[] { columnName}); statement.setString(1, my name); statement.executeUpdate(); ResultSet results = statement.getGeneratedKeys(); results.next(); int id = results.getInt(1); System.out.println(column name=+columnName+: +id); } } public static void main(String[] args) throws Exception { testClientDriver(); testEmbeddedDriver(); } } 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ódzki Statement.executeUpdate(insertSql, int[] columnIndexes) and Statement/executeUpdate(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 { static String createTableSql = CREATE TABLE tbl (id integer primary key generated always as identity, name varchar(200)); static String insertSql = INSERT INTO tbl(name) values('value'); static String driver = org.apache.derby.jdbc.EmbeddedDriver; static String[] idColName = { id }; public static void main(String[] args) throws Exception { Class.forName(driver); Connection conn = DriverManager .getConnection(jdbc:derby:testDb;create=true); conn.setAutoCommit(false); Statement stmt = conn.createStatement(); ResultSet rs; stmt.executeUpdate(createTableSql); stmt.executeUpdate(insertSql, idColName); rs = stmt.getGeneratedKeys();
[jira] [Commented] (DERBY-4921) Statement.executeUpdate(String sql, String[] columnNames) throws ERROR X0X0F.S exception with EmbeddedDriver
[ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13174692#comment-13174692 ] Knut Anders Hatlen commented on DERBY-4921: --- Note that the column name arguments in the setter and updater methods of ResultSet are specified to be case insensitive (which is even more liberal than Dag's proposal). Derby follows the spec for those methods. There is no such mentioning in the JDBC spec (as far as I have found) about the column names in Statement.executeUpdate(String,String[]). If we were to make it more liberal, it might make sense to make it consistent with ResultSet's methods, but it would of course be better if the JDBC spec had provided some guidance on the matter. 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ódzki Statement.executeUpdate(insertSql, int[] columnIndexes) and Statement/executeUpdate(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 { static String createTableSql = CREATE TABLE tbl (id integer primary key generated always as identity, name varchar(200)); static String insertSql = INSERT INTO tbl(name) values('value'); static String driver = org.apache.derby.jdbc.EmbeddedDriver; static String[] idColName = { id }; public static void main(String[] args) throws Exception { Class.forName(driver); Connection conn = DriverManager .getConnection(jdbc:derby:testDb;create=true); conn.setAutoCommit(false); Statement stmt = conn.createStatement(); ResultSet rs; stmt.executeUpdate(createTableSql); stmt.executeUpdate(insertSql, idColName); rs = stmt.getGeneratedKeys(); if (rs.next()) { int id = rs.getInt(1); } conn.commit(); } } Result Exception in thread main java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:95) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:256) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:391) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2269) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1321) at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:625) at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(EmbedStatement.java:246) at GetGeneratedKeysTest.main(GetGeneratedKeysTest.java:23) Caused by: java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:119) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:70) ... 9 more Caused by: ERROR X0X0F: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:303) at org.apache.derby.impl.sql.execute.InsertResultSet.verifyAutoGeneratedColumnsNames(InsertResultSet.java:689) at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:419) at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:436) at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:317) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1232) ... 3 more -- This message is automatically generated by JIRA. If you think it was sent
[jira] [Commented] (DERBY-4921) Statement.executeUpdate(String sql, String[] columnNames) throws ERROR X0X0F.S exception with EmbeddedDriver
[ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13174721#comment-13174721 ] Knut Anders Hatlen commented on DERBY-4921: --- (...) The only other case sensitive database I know is Oracle, (...) Another example is PostgreSQL. The following code fails: s.executeUpdate(create table t(x serial)); s.executeUpdate(insert into t values (default), new String[]{X}); == Exception in thread main org.postgresql.util.PSQLException: ERROR: column X does not exist Changing the column name argument in the latter statement to lowercase (new String[]{x}) makes it work. PostgreSQL stores unquoted identifiers in lowercase, whereas Derby stores them in uppercase, so it's not the exact same examples that cause problems on the two databases, but at least they behave similarly in the sense that they treat the argument as case-sensitive. 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ódzki Statement.executeUpdate(insertSql, int[] columnIndexes) and Statement/executeUpdate(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 { static String createTableSql = CREATE TABLE tbl (id integer primary key generated always as identity, name varchar(200)); static String insertSql = INSERT INTO tbl(name) values('value'); static String driver = org.apache.derby.jdbc.EmbeddedDriver; static String[] idColName = { id }; public static void main(String[] args) throws Exception { Class.forName(driver); Connection conn = DriverManager .getConnection(jdbc:derby:testDb;create=true); conn.setAutoCommit(false); Statement stmt = conn.createStatement(); ResultSet rs; stmt.executeUpdate(createTableSql); stmt.executeUpdate(insertSql, idColName); rs = stmt.getGeneratedKeys(); if (rs.next()) { int id = rs.getInt(1); } conn.commit(); } } Result Exception in thread main java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:95) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:256) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:391) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2269) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1321) at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:625) at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(EmbedStatement.java:246) at GetGeneratedKeysTest.main(GetGeneratedKeysTest.java:23) Caused by: java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:119) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:70) ... 9 more Caused by: ERROR X0X0F: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:303) at org.apache.derby.impl.sql.execute.InsertResultSet.verifyAutoGeneratedColumnsNames(InsertResultSet.java:689) at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:419) at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:436) at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:317) at
[jira] [Commented] (DERBY-4921) Statement.executeUpdate(String sql, String[] columnNames) throws ERROR X0X0F.S exception with EmbeddedDriver
[ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13174436#comment-13174436 ] Stephen Kestle commented on DERBY-4921: --- I would think this is *not* expected behaviour. The only other case sensitive database I know is Oracle, and it is case insensitive unless you explicitly make it case sensitive by quoting the column. A collegue of mine has spent 2 days trying to get derby working with hibernate for unit tests, and you should know that it seems to be impossible to fix this issue without changing the mapping files (which are loath to change since they are actually deployed). Even if we quote all the columns, hibernate complains that it can't find UNIQUEID (if we don't quote, hibernate can't execute an update with uniqueId). Regardless of whether it's derby, or hibernate, or some of our own JDBC code, this is just far too much work to have to try and figure out when _it's not expected_. P.S. {quote}I believe this is the expected behaviour.{quote} Really? I could understand a developer saying this, are there any users (of derby==general developers) that would actually expect this? 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ódzki Statement.executeUpdate(insertSql, int[] columnIndexes) and Statement/executeUpdate(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 { static String createTableSql = CREATE TABLE tbl (id integer primary key generated always as identity, name varchar(200)); static String insertSql = INSERT INTO tbl(name) values('value'); static String driver = org.apache.derby.jdbc.EmbeddedDriver; static String[] idColName = { id }; public static void main(String[] args) throws Exception { Class.forName(driver); Connection conn = DriverManager .getConnection(jdbc:derby:testDb;create=true); conn.setAutoCommit(false); Statement stmt = conn.createStatement(); ResultSet rs; stmt.executeUpdate(createTableSql); stmt.executeUpdate(insertSql, idColName); rs = stmt.getGeneratedKeys(); if (rs.next()) { int id = rs.getInt(1); } conn.commit(); } } Result Exception in thread main java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:95) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:256) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:391) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2269) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1321) at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:625) at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(EmbedStatement.java:246) at GetGeneratedKeysTest.main(GetGeneratedKeysTest.java:23) Caused by: java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:119) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:70) ... 9 more Caused by: ERROR X0X0F: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:303) at org.apache.derby.impl.sql.execute.InsertResultSet.verifyAutoGeneratedColumnsNames(InsertResultSet.java:689) at
[jira] [Commented] (DERBY-4921) Statement.executeUpdate(String sql, String[] columnNames) throws ERROR X0X0F.S exception with EmbeddedDriver
[ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13174575#comment-13174575 ] Dag H. Wanvik commented on DERBY-4921: -- I agree this is not intuitive. It would be better I think, if all the JDBC API methods that take column names were case folded to the internal canonical form (upper cased as per the SQL standard) unless quoted. There has been discussions about this in the past, not sure why it was never changed. 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ódzki Statement.executeUpdate(insertSql, int[] columnIndexes) and Statement/executeUpdate(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 { static String createTableSql = CREATE TABLE tbl (id integer primary key generated always as identity, name varchar(200)); static String insertSql = INSERT INTO tbl(name) values('value'); static String driver = org.apache.derby.jdbc.EmbeddedDriver; static String[] idColName = { id }; public static void main(String[] args) throws Exception { Class.forName(driver); Connection conn = DriverManager .getConnection(jdbc:derby:testDb;create=true); conn.setAutoCommit(false); Statement stmt = conn.createStatement(); ResultSet rs; stmt.executeUpdate(createTableSql); stmt.executeUpdate(insertSql, idColName); rs = stmt.getGeneratedKeys(); if (rs.next()) { int id = rs.getInt(1); } conn.commit(); } } Result Exception in thread main java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:95) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:256) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:391) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2269) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1321) at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:625) at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(EmbedStatement.java:246) at GetGeneratedKeysTest.main(GetGeneratedKeysTest.java:23) Caused by: java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:119) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:70) ... 9 more Caused by: ERROR X0X0F: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:303) at org.apache.derby.impl.sql.execute.InsertResultSet.verifyAutoGeneratedColumnsNames(InsertResultSet.java:689) at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:419) at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:436) at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:317) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1232) ... 3 more -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (DERBY-4921) Statement.executeUpdate(String sql, String[] columnNames) throws ERROR X0X0F.S exception with EmbeddedDriver
[ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13174596#comment-13174596 ] Bryan Pendleton commented on DERBY-4921: +1 to Dag's suggestion. Is this hard? 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ódzki Statement.executeUpdate(insertSql, int[] columnIndexes) and Statement/executeUpdate(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 { static String createTableSql = CREATE TABLE tbl (id integer primary key generated always as identity, name varchar(200)); static String insertSql = INSERT INTO tbl(name) values('value'); static String driver = org.apache.derby.jdbc.EmbeddedDriver; static String[] idColName = { id }; public static void main(String[] args) throws Exception { Class.forName(driver); Connection conn = DriverManager .getConnection(jdbc:derby:testDb;create=true); conn.setAutoCommit(false); Statement stmt = conn.createStatement(); ResultSet rs; stmt.executeUpdate(createTableSql); stmt.executeUpdate(insertSql, idColName); rs = stmt.getGeneratedKeys(); if (rs.next()) { int id = rs.getInt(1); } conn.commit(); } } Result Exception in thread main java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:95) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:256) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:391) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2269) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1321) at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:625) at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(EmbedStatement.java:246) at GetGeneratedKeysTest.main(GetGeneratedKeysTest.java:23) Caused by: java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:119) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:70) ... 9 more Caused by: ERROR X0X0F: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:303) at org.apache.derby.impl.sql.execute.InsertResultSet.verifyAutoGeneratedColumnsNames(InsertResultSet.java:689) at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:419) at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:436) at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:317) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1232) ... 3 more -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (DERBY-4921) Statement.executeUpdate(String sql, String[] columnNames) throws ERROR X0X0F.S exception with EmbeddedDriver
[ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12936010#action_12936010 ] Knut Anders Hatlen commented on DERBY-4921: --- I believe this is the expected behaviour. There is no column called 'id' in the table because Derby stores unquoted identifiers in upper case. The column name is therefore 'ID'. To get the example code to work, you can either change the CREATE TABLE statement to quote the column name, like this: static String createTableSql = CREATE TABLE tbl (\id\ integer primary key generated always as identity, name varchar(200)); Or you can change the column name argument to executeUpdate() to upper case, like this: static String[] idColName = { ID }; Hope this helps. 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ódzki Statement.executeUpdate(insertSql, int[] columnIndexes) and Statement/executeUpdate(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 { static String createTableSql = CREATE TABLE tbl (id integer primary key generated always as identity, name varchar(200)); static String insertSql = INSERT INTO tbl(name) values('value'); static String driver = org.apache.derby.jdbc.EmbeddedDriver; static String[] idColName = { id }; public static void main(String[] args) throws Exception { Class.forName(driver); Connection conn = DriverManager .getConnection(jdbc:derby:testDb;create=true); conn.setAutoCommit(false); Statement stmt = conn.createStatement(); ResultSet rs; stmt.executeUpdate(createTableSql); stmt.executeUpdate(insertSql, idColName); rs = stmt.getGeneratedKeys(); if (rs.next()) { int id = rs.getInt(1); } conn.commit(); } } Result Exception in thread main java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:95) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:256) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:391) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2269) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1321) at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:625) at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(EmbedStatement.java:246) at GetGeneratedKeysTest.main(GetGeneratedKeysTest.java:23) Caused by: java.sql.SQLException: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:119) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:70) ... 9 more Caused by: ERROR X0X0F: Table 'TBL' does not have an auto-generated column named 'id'. at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:303) at org.apache.derby.impl.sql.execute.InsertResultSet.verifyAutoGeneratedColumnsNames(InsertResultSet.java:689) at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:419) at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:436) at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:317) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1232) ... 3 more -- This message is automatically generated by JIRA. - You can reply to