java.sql.SQLException

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.

  • I'm using LocalSessionFactoryBean.updateDatabaseSchema and it's not working very well on SQL Server. Basically, if there are errors in the upgrade scripts generated by Hibernate, the update does not go through. I'm not sure exactly why this is happening but perhaps some log output and a couple fixes to the problem will help illustrate what's going on. Here is some log output: DEBUG (LocalSessionFactoryBean:executeSchemaScript) - Executing schema statement: create table usergrouppermissions (usergroupid int not null, permissionid int not null, primary key (usergroupid, permissionid)) DEBUG (LocalSessionFactoryBean:executeSchemaScript) - Executing schema statement: alter table files add constraint FK5CEBA778EB197A2 foreign key (createdbyuserid) references users WARN (LocalSessionFactoryBean:executeSchemaScript) - Unsuccessful schema statement: alter table files add constraint FK5CEBA778EB197A2 foreign key (createdbyuserid) references users java.sql.SQLException: Cannot alter table 'files' because this table does not exist in database 'tester'. at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:364) at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2778) at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2214) at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:597) at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:465) at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:427) at net.sourceforge.jtds.jdbc.JtdsStatement.executeUpdate(JtdsStatement.java:1000) at net.sourceforge.jtds.jdbc.JtdsStatement.executeUpdate(JtdsStatement.java:906) Then, later on in the log file.... WARN (LocalSessionFactoryBean:executeSchemaScript) - Unsuccessful schema statement: alter table usergrouppermissions add constraint FK11713E7042F124D0 foreign key (usergroupid) references usergroups java.sql.SQLException: Cannot alter table 'usergrouppermissions' because this table does not exist in database 'tester'. at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:364) at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2778) at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2214) at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:597) at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:465) at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:427) at net.sourceforge.jtds.jdbc.JtdsStatement.executeUpdate(JtdsStatement.java:1000) at net.sourceforge.jtds.jdbc.JtdsStatement.executeUpdate(JtdsStatement.java:906) at org.apache.commons.dbcp.DelegatingStatement.executeUpdate(DelegatingStatement.java:225) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.executeSchemaScript(LocalSessionFactoryBean.java:888) at org.springframework.orm.hibernate3.LocalSessionFactoryBean$3.doInHibernate(LocalSessionFactoryBean.java:864) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:311) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:288) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.updateDatabaseSchema(LocalSessionFactoryBean.java:857) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:715) I'm not exactly clear why this is happening, but there are two possible solutions to the issue. Ideally, I would like for either of these solutions to be adopted as a chance to LocalSessionFactoryBean. If you don't like either of the changes, it would be at nice to at least introduce a configuration variable so that subclassing LocalSessionFactoryBean isn't needed just to make the updateDatabaseSchema method work on SQL Server. One solution is to set the flush mode on HibernateTemplate to EAGER in the updateDatabaseSchema method. The other solution is to setAutoCommit(true) in executeSchemaScript. I honestly think either or both solution should be OK, because most databases I've worked with (Oracle, MySQL) automatically commit DDL statements anyway, even if the statement appears in a transaction which is later rolled back. It looks like SQL Server doesn't though.
    via by Matthew Sgarlata,
  • I'm using LocalSessionFactoryBean.updateDatabaseSchema and it's not working very well on SQL Server. Basically, if there are errors in the upgrade scripts generated by Hibernate, the update does not go through. I'm not sure exactly why this is happening but perhaps some log output and a couple fixes to the problem will help illustrate what's going on. Here is some log output: DEBUG (LocalSessionFactoryBean:executeSchemaScript) - Executing schema statement: create table usergrouppermissions (usergroupid int not null, permissionid int not null, primary key (usergroupid, permissionid)) DEBUG (LocalSessionFactoryBean:executeSchemaScript) - Executing schema statement: alter table files add constraint FK5CEBA778EB197A2 foreign key (createdbyuserid) references users WARN (LocalSessionFactoryBean:executeSchemaScript) - Unsuccessful schema statement: alter table files add constraint FK5CEBA778EB197A2 foreign key (createdbyuserid) references users java.sql.SQLException: Cannot alter table 'files' because this table does not exist in database 'tester'. at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:364) at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2778) at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2214) at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:597) at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:465) at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:427) at net.sourceforge.jtds.jdbc.JtdsStatement.executeUpdate(JtdsStatement.java:1000) at net.sourceforge.jtds.jdbc.JtdsStatement.executeUpdate(JtdsStatement.java:906) Then, later on in the log file.... WARN (LocalSessionFactoryBean:executeSchemaScript) - Unsuccessful schema statement: alter table usergrouppermissions add constraint FK11713E7042F124D0 foreign key (usergroupid) references usergroups java.sql.SQLException: Cannot alter table 'usergrouppermissions' because this table does not exist in database 'tester'. at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:364) at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2778) at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2214) at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:597) at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:465) at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:427) at net.sourceforge.jtds.jdbc.JtdsStatement.executeUpdate(JtdsStatement.java:1000) at net.sourceforge.jtds.jdbc.JtdsStatement.executeUpdate(JtdsStatement.java:906) at org.apache.commons.dbcp.DelegatingStatement.executeUpdate(DelegatingStatement.java:225) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.executeSchemaScript(LocalSessionFactoryBean.java:888) at org.springframework.orm.hibernate3.LocalSessionFactoryBean$3.doInHibernate(LocalSessionFactoryBean.java:864) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:311) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:288) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.updateDatabaseSchema(LocalSessionFactoryBean.java:857) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:715) I'm not exactly clear why this is happening, but there are two possible solutions to the issue. Ideally, I would like for either of these solutions to be adopted as a chance to LocalSessionFactoryBean. If you don't like either of the changes, it would be at nice to at least introduce a configuration variable so that subclassing LocalSessionFactoryBean isn't needed just to make the updateDatabaseSchema method work on SQL Server. One solution is to set the flush mode on HibernateTemplate to EAGER in the updateDatabaseSchema method. The other solution is to setAutoCommit(true) in executeSchemaScript. I honestly think either or both solution should be OK, because most databases I've worked with (Oracle, MySQL) automatically commit DDL statements anyway, even if the statement appears in a transaction which is later rolled back. It looks like SQL Server doesn't though.
    via by Matthew Sgarlata,
  • Error on create trigger
    via symmetricds by nuttinjeff
    ,
  • SelectiveDataReplication
    via symmetricds by manmadh
    ,
  • Unit Tests Failing
    via jtds by brownie74
    ,
  • Confluence 3.5.x upgrade failed for SQL Server with case sensitive collation during ContentPermissionConstraintsUpgradeTask. The query that Confluence is trying to execute is in lower case, but the database is configured to Upper case. As a result some columns are not recognized. Sample error: {noformat} 2011-04-18 19:14:35,605 ERROR [main] [atlassian.confluence.upgrade.UpgradeLauncherServletContextListener] contextInitialized Upgrade failed, application will not start: Schema upgrade task [ com.atlassian.confluence.upgrade.upgradetask.ContentPermissionConstraintsUpgradeTask@1c669dc ] failed due to : StatementCallback; bad SQL grammar [DELETE FROM CONTENT_PERM WHERE username IS NULL AND groupname IS NULL]; nested exception is java.sql.SQLException: Invalid column name 'username'. com.atlassian.confluence.upgrade.UpgradeException: Schema upgrade task [ com.atlassian.confluence.upgrade.upgradetask.ContentPermissionConstraintsUpgradeTask@1c669dc ] failed due to : StatementCallback; bad SQL grammar [DELETE FROM CONTENT_PERM WHERE username IS NULL AND groupname IS NULL]; nested exception is java.sql.SQLException: Invalid column name 'username'. at com.atlassian.confluence.upgrade.AbstractUpgradeManager.runSchemaUpgradeTasks(AbstractUpgradeManager.java:292) at com.atlassian.confluence.upgrade.AbstractUpgradeManager.upgradeSchema(AbstractUpgradeManager.java:235) at com.atlassian.confluence.upgrade.AbstractUpgradeManager.upgrade(AbstractUpgradeManager.java:87) at com.atlassian.confluence.upgrade.impl.DefaultUpgradeManager.upgrade(DefaultUpgradeManager.java:139) at com.atlassian.confluence.upgrade.UpgradeLauncherServletContextListener.contextInitialized(UpgradeLauncherServletContextListener.java:28) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4205) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4704) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:840) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Caused by: org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [DELETE FROM CONTENT_PERM WHERE username IS NULL AND groupname IS NULL]; nested exception is java.sql.SQLException: Invalid column name 'username'. at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:230) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:354) at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:469) at com.atlassian.confluence.upgrade.upgradetask.ContentPermissionConstraintsUpgradeTask.removePermissionEntriesWithNoGroupAndUser(ContentPermissionConstraintsUpgradeTask.java:84) at com.atlassian.confluence.upgrade.upgradetask.ContentPermissionConstraintsUpgradeTask.doBeforeUpgrade(ContentPermissionConstraintsUpgradeTask.java:63) at com.atlassian.confluence.upgrade.upgradetask.AbstractConstraintCreationUpgradeTask.doUpgrade(AbstractConstraintCreationUpgradeTask.java:123) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy34.doUpgrade(Unknown Source) at com.atlassian.confluence.upgrade.AbstractUpgradeManager.runSchemaUpgradeTasks(AbstractUpgradeManager.java:287) ... 19 more Caused by: java.sql.SQLException: Invalid column name 'username'. at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368) at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820) at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2258) at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:632) at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:584) at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:546) at net.sourceforge.jtds.jdbc.JtdsStatement.executeImpl(JtdsStatement.java:723) at net.sourceforge.jtds.jdbc.JtdsStatement.executeUpdate(JtdsStatement.java:1166) at net.sourceforge.jtds.jdbc.JtdsStatement.executeUpdate(JtdsStatement.java:1119) at com.mchange.v2.c3p0.impl.NewProxyStatement.executeUpdate(NewProxyStatement.java:64) at org.springframework.jdbc.core.JdbcTemplate$1UpdateStatementCallback.doInStatement(JdbcTemplate.java:459) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:343) ... 35 more caused by: java.sql.SQLException: Invalid column name 'groupname'. at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368) at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820) at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2258) at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:637) at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:584) at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:546) at net.sourceforge.jtds.jdbc.JtdsStatement.executeImpl(JtdsStatement.java:723) at net.sourceforge.jtds.jdbc.JtdsStatement.executeUpdate(JtdsStatement.java:1166) at net.sourceforge.jtds.jdbc.JtdsStatement.executeUpdate(JtdsStatement.java:1119) at com.mchange.v2.c3p0.impl.NewProxyStatement.executeUpdate(NewProxyStatement.java:64) at org.springframework.jdbc.core.JdbcTemplate$1UpdateStatementCallback.doInStatement(JdbcTemplate.java:459) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:343) at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:469) at com.atlassian.confluence.upgrade.upgradetask.ContentPermissionConstraintsUpgradeTask.removePermissionEntriesWithNoGroupAndUser(ContentPermissionConstraintsUpgradeTask.java:84) at com.atlassian.confluence.upgrade.upgradetask.ContentPermissionConstraintsUpgradeTask.doBeforeUpgrade(ContentPermissionConstraintsUpgradeTask.java:63) at com.atlassian.confluence.upgrade.upgradetask.AbstractConstraintCreationUpgradeTask.doUpgrade(AbstractConstraintCreationUpgradeTask.java:123) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy34.doUpgrade(Unknown Source) at com.atlassian.confluence.upgrade.AbstractUpgradeManager.runSchemaUpgradeTasks(AbstractUpgradeManager.java:287) at com.atlassian.confluence.upgrade.AbstractUpgradeManager.upgradeSchema(AbstractUpgradeManager.java:235) at com.atlassian.confluence.upgrade.AbstractUpgradeManager.upgrade(AbstractUpgradeManager.java:87) at com.atlassian.confluence.upgrade.impl.DefaultUpgradeManager.upgrade(DefaultUpgradeManager.java:139) at com.atlassian.confluence.upgrade.UpgradeLauncherServletContextListener.contextInitialized(UpgradeLauncherServletContextListener.java:28) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4205) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4704) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:840) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) 2011-04-18 19:14:35,621 ERROR [main] [atlassian.confluence.upgrade.UpgradeLauncherServletContextListener] contextInitialized 1 errors were encountered during upgrade: 2011-04-18 19:14:35,621 ERROR [main] [atlassian.confluence.upgrade.UpgradeLauncherServletContextListener] contextInitialized 1: StatementCallback; bad SQL grammar [DELETE FROM CONTENT_PERM WHERE username IS NULL AND groupname IS NULL]; nested exception is java.sql.SQLException: Invalid column name 'username'. {noformat}
    via by Roy Hartono [Atlassian],
    • java.sql.SQLException: Cannot alter table 'files' because this table does not exist in database 'tester'. at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:364) at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2778) at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2214) at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:597) at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:465) at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:427) at net.sourceforge.jtds.jdbc.JtdsStatement.executeUpdate(JtdsStatement.java:1000) at net.sourceforge.jtds.jdbc.JtdsStatement.executeUpdate(JtdsStatement.java:906)

    Users with the same issue

    odd
    72 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Eric
    3 times, last one,
    Unknown visitor1 times, last one,
    22 more bugmates