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

Atlassian JIRA | Renan Battaglin | 6 years ago
  1. 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
  2. 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
  3. 0

    How to PreparedStatement sql with ON DUPLICATE KEY UPDATE?

    Stack Overflow | 2 years ago | membersound
    org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar; nested exception is org.postgresql.util.PSQLException: FEHLER: Syntaxerror at ?ON?
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

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

    Problem with SQL Server connection from a Linux machine - Database Administrators Stack Exchange

    stackexchange.com | 1 year ago
    org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar []; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: Cannot open backup device 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\media\baks\mydbbak.bak'. Operating system error 3(failed to retrieve text for this error. Reason: 15105).

    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 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()
    2. Spring Framework
      JdbcTemplate.execute
      1. org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:220)
      2. org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
      3. org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:407)
      3 frames