From: John Embretsen <[EMAIL PROTECTED]>CREATE TABLE "ADDTestCasesResults" ( "ADDTestCasesResultsID" BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY PRIMARY KEY , "chipRelease" VARCHAR(10) NOT NULL , "testCaseID" BIGINT NOT NULL , "actualSum" BIGINT NOT NULL ) The following Java statement fails with the same error message: statement.executeUpdate( "INSERT INTO \"ADDTestCasesResults\" ( \"chipRelease\", \"testCaseID\", \"actualSum\" ) VALUES( " + simulationResult.getChipRelease() + ", " + Long.toString( simulationResult.getTestCaseID() ) + ", " + Long.toString( simulationResult.getActualSum() ) + " )" );Both observations were made with Derby 10.2.1.6. Either it's my error, or there is a bug in one of the software layers under my application (e.g. JDBC or Derby).I've seen this error message before, and it is often caused by quoting errors. Actually, that is a nice way of doing it. The SQL statement passed to Connection.prepareStatement is simpler. Even the second parameter to PreparedStatement.setLong is simpler. Furthermore, while not useful in all cases (it is useful in mine), the PreparedStatement object can then be used to efficiently execute the parameterized statement multiple times. Finally, and most importantly, it avoids whatever the above problem was (i.e. it works).I would suggest using PreparedStatement instead, which lets you avoid quoting strings such as 'Sputnik001'.Example: selectSql = "SELECT * FROM \"ADDTestCasesResults\" WHERE \"chipRelease\" = ? AND \"testCaseID\" = ?"; PreparedStatement pStmt = conn.prepareStatement(selectSql); pStmt.setString(1, simulationResult.getChipRelease()); pStmt.setLong(2, simulationResult.getTestCaseID()); resultSet = pStmt.executeQuery(); If you are using the same statement more than once, prepare it once and then reuse it (prepareStatement(), ..., setXXX(), executeQuery(), ..., setXXX(), executeQuery(), ...). Thank you, John. |
- Re: WHERE clause John Embretsen
- Re: WHERE clause Alan M. Feldstein
- Re: WHERE clause John Embretsen
