org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist

nabble.com | 1 month ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    Camel - Users - camel-sql IN query number of parameters mismatch

    nabble.com | 1 month ago
    org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
  2. 0

    Can you explain why @Transactional not rolling back

    Stack Overflow | 4 years ago | Wasif
    org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [CREATE TABLE XYZ(ID NUMBER NOT NULL, NAME VARCHAR2(35), UPDATE DATE(7), primary key(ID))]; nested exception is java.sql.SQLSyntaxErrorException: ORA-00904: : invalid identifier
  3. 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
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 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
  6. 0

    *Problem 1:* * Name in uppercased for "CWD_DIRECTORY" causes issues in DBs with lowercased table names: {code} org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [SELECT id, directory_name FROM CWD_DIRECTORY WHERE directory_type = 'INTERNAL']; nested exception is java.sql.SQLException: Table 'jira4.CWD_DIRECTORY' doesn't exist at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:220) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:407) {code} *Problem 2:* * Ambiguity in the Membership Query: {code} Cause : org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [SELECT usr.user_name AS user_name, grp.group_name as group_name FROM cwd_membership AS mem INNER JOIN cwd_group AS grp ON mem.parent_id = grp.id INNER JOIN cwd_user as usr ON mem.child_id = usr.ID WHERE membership_type = 'GROUP_USER' AND directory_id = ?]; Column 'directory_id' in where clause is ambiguous; nested exception is java.sql.SQLException: Column 'directory_id' in where clause is ambiguous Stack Trace : org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [SELECT usr.user_name AS user_name, grp.group_name as group_name FROM cwd_membership AS mem INNER JOIN cwd_group AS grp ON mem.parent_id = grp.id INNER JOIN cwd_user as usr ON mem.child_id = usr.ID WHERE membership_type = 'GROUP_USER' AND directory_id = ?]; Column 'directory_id' in where clause is ambiguous; nested exception is java.sql.SQLException: Column 'directory_id' in where clause is ambiguous at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:100) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80) {code} I fixed the problem adding "mem." to the "WHERE" conditions: {code} SELECT usr.user_name AS user_name, grp.group_name as group_name FROM cwd_membership AS mem INNER JOIN cwd_group AS grp ON mem.parent_id = grp.id INNER JOIN cwd_user as usr ON mem.child_id = usr.ID WHERE mem.membership_type = 'GROUP_USER' AND mem.directory_id = ?; {code} More details and full stack traces: https://support.atlassian.com/browse/CWDSUP-4676

    Atlassian JIRA | 6 years ago | Renan Battaglin
    org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [SELECT id, directory_name FROM CWD_DIRECTORY WHERE directory_type = 'INTERNAL']; nested exception is java.sql.SQLException: Table 'jira4.CWD_DIRECTORY' doesn't exist

    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

      PreparedStatementCallback; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist

      at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate()
    2. Spring Framework
      JdbcTemplate.execute
      1. org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:231)
      2. org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
      3. org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:649)
      3 frames
    3. Camel :: SQL
      SqlProducer.process
      1. org.apache.camel.component.sql.SqlProducer.process(SqlProducer.java:116)
      1 frame