org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar** [SELECT * FROM (SELECT RC.EXT_CODICE_FISCALE AS CODICE_FISCALE, ROWNUM as TMP_ROW_NUM FROM RAPPORTO_CATASTALE RC, DOCUMENTO D WHERE RC.ATTUALE = 'S' AND RC.ID_DOCUMENTO = D.ID_DOCUMENTO AND D.DT_OSCURAMENTO IS NULL ORDER BY RC.DT_AGGIORNAMENTO ASC) WHERE ROWNUM <= 100]; nested exception is java.sql.SQLException: Nome colonna non valido

Stack Overflow | user3278977 | 4 months ago
  1. 0

    Spring Batch. org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar

    Stack Overflow | 4 months ago | user3278977
    org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar** [SELECT * FROM (SELECT RC.EXT_CODICE_FISCALE AS CODICE_FISCALE, ROWNUM as TMP_ROW_NUM FROM RAPPORTO_CATASTALE RC, DOCUMENTO D WHERE RC.ATTUALE = 'S' AND RC.ID_DOCUMENTO = D.ID_DOCUMENTO AND D.DT_OSCURAMENTO IS NULL ORDER BY RC.DT_AGGIORNAMENTO ASC) WHERE ROWNUM <= 100]; nested exception is java.sql.SQLException: Nome colonna non valido
  2. 0

    Removed error-irrelevant translation stack frames from exception stack trace after exceptions were created by an SQLExceptionTranslator: When debugging Spring-JDBC queries, I find it distracting that the top stack frames always refer to SQLExceptionTranslator which is only called after an error occured that caused the exception. The translator only translates a "raw" exception into a richer exception. Therefore, I suggest that these stack entries are removed before the enriched exception is rethrown by the JdbcTemplate. It is a detail, but I believe the exception stack trace should not get polluted with details that merely reflect an implementation detail. This can also distract a user that tries debugging his/her application and who does not know how the exception handling is implemented in Spring. An example of how the stack trace looks like when using an invalid SQL statement within JdbcTemplate: {noformat} org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [This is not valid SQL]; nested exception is java.sql.SQLException: ORA-00900: invalid SQL statement at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:233) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:603) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:637) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:666) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:674) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:714) at com.example.Main.main(Main.java:17) Caused by: java.sql.SQLException: ORA-00900: invalid SQL statement {noformat} With the patch the stack trace would look like: {noformat} org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [This is not valid SQL]; nested exception is java.sql.SQLException: ORA-00900: invalid SQL statement at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:614) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:637) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:666) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:674) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:714) at com.example.Main.main(Main.java:17) Caused by: java.sql.SQLException: ORA-00900: invalid SQL statement {noformat} In this example, the exception is catched withing JdbcTemplate.execute, wrapped by an instance of SQLErrorCodeSQLExceptionTranslator and then rethrown. Since the SQLErrorCodeSQLExceptionTranslator is responsible for instantiating the wrapping exception, the exception's stack trace is pointing to the translator since Exception.fillInStackTrace is called in the exception's constructor (this is the default implementation of a Java exception.)

    Spring JIRA | 3 years ago | Rafael Winterhalter
    org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [This is not valid SQL]; nested exception is java.sql.SQLException: ORA-00900: invalid SQL statement
  3. 0

    How to use Stored procedures with parameter in Mule

    Stack Overflow | 3 years ago
    org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [CALL sp_myStoredProcedure(?) ]; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '@P0'.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Spring JDBCTemplate throwing BadSqlGrammarException

    Stack Overflow | 1 year ago | Chakri
    org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [ SELECT DISTINCT O.ORGID FROM ORGANISATIONS O WHERE O.ORGTYPE NOT IN ('P','G') AND O.USERID = 40]; nested exception is java.sql.SQLException: Invalid column name
  6. 0

    Nested exception is com.microsoft.sqlserver.jdbc.SQLServerException:The server failed to resume the transaction

    Stack Overflow | 7 months ago | User146378
    org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [{call storeproc1(?,?,?,?,?,?,?,?)}]; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: The server failed to resume the transaction. Desc:a600000018.

    4 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.springframework.jdbc.BadSqlGrammarException

      StatementCallback; bad SQL grammar** [SELECT * FROM (SELECT RC.EXT_CODICE_FISCALE AS CODICE_FISCALE, ROWNUM as TMP_ROW_NUM FROM RAPPORTO_CATASTALE RC, DOCUMENTO D WHERE RC.ATTUALE = 'S' AND RC.ID_DOCUMENTO = D.ID_DOCUMENTO AND D.DT_OSCURAMENTO IS NULL ORDER BY RC.DT_AGGIORNAMENTO ASC) WHERE ROWNUM <= 100]; nested exception is java.sql.SQLException: Nome colonna non valido

      at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate()
    2. Spring Framework
      JdbcTemplate.query
      1. org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:237)
      2. org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
      3. org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:407)
      4. org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:456)
      5. org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:464)
      5 frames
    3. Spring Batch Infrastructure
      AbstractItemCountingItemStreamItemReader.read
      1. org.springframework.batch.item.database.JdbcPagingItemReader.doReadPage(JdbcPagingItemReader.java:208)
      2. org.springframework.batch.item.database.AbstractPagingItemReader.doRead(AbstractPagingItemReader.java:107)
      3. org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.read(AbstractItemCountingItemStreamItemReader.java:85)
      3 frames
    4. Spring Batch Core
      SimpleChunkProvider$1.doInIteration
      1. org.springframework.batch.core.step.item.SimpleChunkProvider.doRead(SimpleChunkProvider.java:90)
      2. org.springframework.batch.core.step.item.SimpleChunkProvider.read(SimpleChunkProvider.java:148)
      3. org.springframework.batch.core.step.item.SimpleChunkProvider$1.doInIteration(SimpleChunkProvider.java:108)
      3 frames
    5. Spring Batch Infrastructure
      RepeatTemplate.iterate
      1. org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:367)
      2. org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:214)
      3. org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143)
      3 frames
    6. Spring Batch Core
      TaskletStep$ChunkTransactionCallback.doInTransaction
      1. org.springframework.batch.core.step.item.SimpleChunkProvider.provide(SimpleChunkProvider.java:103)
      2. org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:68)
      3. org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:386)
      3 frames
    7. Spring Tx
      TransactionTemplate.execute
      1. org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:131)
      1 frame
    8. Spring Batch Core
      TaskletStep$2.doInChunkContext
      1. org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:264)
      1 frame