Search code examples
sqlgrailslegacy

Grails table not found error on SQL 2008 legacy table


I'm trying to link a new Grails project to a pre-existing SQL server 2008 database, trouble is when I try to list/update or anything nothing works and I get an error reading

Table "TEST_EXEC_QUEUE" not found; SQL statement: select top 10 this_.id as id0_0_, this_.Env as Env0_0_, this_.Priority as Priority0_0_, this_.State as State0_0_, this_.subSystem as subSystem0_0_, this_.system as system0_0_, this_.test_scenario_id as test7_0_0_ from test_exec_queue this_ [42102-164]

My datasource.groovy file is: -

dataSource {
    pooled = false
    driverClassName = "net.sourceforge.jtds.jdbc.Driver"
    dialect = "org.hibernate.dialect.SQLServerDialect"
    }

hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = false
    cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}


// environment specific settings
    development {
        dataSource {
            dbCreate = "update"
            url = "jdbc:jtds:sqlserver://UKSQL08;databaseName=Selenium"
        }
    }

and the domain file is as follows, anyone got any ideas...?

package testexecqueue

class TestExecQueueCheck {

    static constraints = {
        test_scenario_id(blank:false)
        myPriority()
        myState()
        myEnv()
        system()
        subSystem()
    }

    static mapping = {
        table "test_exec_queue"
        version false
        columns{

            test_scenario_id column:"test_scenario_id"
            myPriority column:"Priority"
            myState column:"State"
            myEnv column:"Env"
            system column:"system"
            subSystem column:"subSystem"
        }
    }

    Integer test_scenario_id
    Integer myPriority
    String myState
    String myEnv
    String system
    String subSystem
}

Solution

  • This may be not the answer but I found that once I specified an actual account and moved back to a JDBC connection the problem went away, so its something to do with windows service accounts/JTDS which I've yet to investigate further... My DataSource using sqljdbc4 is now as follows and works fine...

    dataSource {
        pooled = true
        driverClassName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
    }
    
    hibernate {
        cache.use_second_level_cache = true
        cache.use_query_cache = false
        cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
    }
    
    
    // environment specific settings
    environments {
        development {
            dataSource {
                dbCreate = 'update' // one of 'create', 'create-drop','update'
                url = "jdbc:sqlserver://localhost;database=TestDB"
        //      databaseName = "..."
            username = "test"
            password = "test"
                dialect = org.hibernate.dialect.SQLServerDialect
                //logSql = true
            }
        }