You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Jarek Przygódzki (JIRA)" <ji...@apache.org> on 2010/11/25 21:09:13 UTC

[jira] Created: (DERBY-4921) Statement.executeUpdate(String sql, String[] columnNames) throws ERROR X0X0F.S exception with EmbeddedDriver

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 this email to add a comment to the issue online.


[jira] Closed: (DERBY-4921) Statement.executeUpdate(String sql, String[] columnNames) throws ERROR X0X0F.S exception with EmbeddedDriver

Posted by "Jarek Przygódzki (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jarek Przygódzki closed DERBY-4921.
-----------------------------------


> 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 this email to add a comment to the issue online.


[jira] [Commented] (DERBY-4921) Statement.executeUpdate(String sql, String[] columnNames) throws ERROR X0X0F.S exception with EmbeddedDriver

Posted by "Bryan Pendleton (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=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] [Closed] (DERBY-4921) Statement.executeUpdate(String sql, String[] columnNames) throws ERROR X0X0F.S exception with EmbeddedDriver

Posted by "Dag H. Wanvik (Closed) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik closed DERBY-4921.
--------------------------------

    Resolution: Invalid
    
> 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

Posted by "Knut Anders Hatlen (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=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 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

Posted by "Knut Anders Hatlen (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=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 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] Resolved: (DERBY-4921) Statement.executeUpdate(String sql, String[] columnNames) throws ERROR X0X0F.S exception with EmbeddedDriver

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen resolved DERBY-4921.
---------------------------------------

            Resolution: Not A Problem
    Bug behavior facts:   (was: [Deviation from standard])

> 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 this email to add a comment to the issue online.


[jira] [Reopened] (DERBY-4921) Statement.executeUpdate(String sql, String[] columnNames) throws ERROR X0X0F.S exception with EmbeddedDriver

Posted by "Dag H. Wanvik (Reopened) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik reopened DERBY-4921:
----------------------------------

    
> 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] [Issue Comment Edited] (DERBY-4921) Statement.executeUpdate(String sql, String[] columnNames) throws ERROR X0X0F.S exception with EmbeddedDriver

Posted by "Dag H. Wanvik (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13174575#comment-13174575 ] 

Dag H. Wanvik edited comment on DERBY-4921 at 12/22/11 2:40 AM:
----------------------------------------------------------------

I agree this is not intuitive. It would be better I think, if for all the JDBC API methods that take column names, 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.

                
      was (Author: dagw):
    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

Posted by "Stephen Kestle (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=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 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

Posted by "Dag H. Wanvik (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=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

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=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 this email to add a comment to the issue online.