org.springframework.jdbc.BadSqlGrammarException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • *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
    via by Renan Battaglin,
  • Problem with SQL Server connection from a Linux machine
    via Database Administrators by u123
    ,
  • *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
    via by Renan Battaglin,
    • org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [update t_table set camel_is_read = 1, date_checked = sysdate where id = ? exception is java.sql.SQLSyntaxErrorException: ORA-00904: "YSDATEHERE": ungültiger Bezeichner at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:237) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:605) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:617) at org.apache.camel.component.sql.DefaultSqlProcessingStrategy.commit(DefaultSqlProcessingStrategy.java:46) at org.apache.camel.component.sql.SqlConsumer.processBatch(SqlConsumer.java:195) at org.apache.camel.component.sql.SqlConsumer$1.doInPreparedStatement(SqlConsumer.java:118) at org.apache.camel.component.sql.SqlConsumer$1.doInPreparedStatement(SqlConsumer.java:91) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:589) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:617) at org.apache.camel.component.sql.SqlConsumer.poll(SqlConsumer.java:91) at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174) at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:724)

    Users with the same issue

    Andreas Häber
    12 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,