2013-03-11 58 views
0

我試圖將一個新的Grails項目鏈接到預先存在的SQL Server 2008數據庫,麻煩的是當我嘗試列出/更新或者什麼都不起作用時,我得到讀取錯誤在SQL 2008遺留表格中找不到Grails表格錯誤

未找到表「TEST_EXEC_QUEUE」; SQL語句: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]

我DataSource.groovy的文件是: -

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" 
     } 
    } 

和域文件內容如下,任何人有任何想法...?

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 
} 

回答

0

這可能不是答案,但我發現,一旦我指定了一個實際的帳戶,並回到JDBC連接問題消失了,所以它與我尚未調查的Windows服務帳戶/ JTDS有關進一步...使用sqljdbc4我的數據源現在是如下,工作正常...

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 
     } 
    } 
+0

此外,如果你想使用Windows身份驗證,你需要確保你把jdbc jar和auth dll放在lib中,我只是把問題lib文件夾中的jar文件,直到我添加了auth dll以及它開始工作,現在意味着我不需要指定用戶帳戶或密碼。 – MorkPork 2013-04-10 16:15:24

0

TestExecQueueCheck域中沒有標識。將字段test_scenario_id重命名爲id。它應該解決問題。

+0

嗯,這並不似乎有所作爲,我已經改變了所有所謂test_scenario_id爲ID的變量,已清理和重新編譯等然後重新運行,我仍然得到同樣的問題...我假設你不意味着更改數據庫字段爲ID你呢? – MorkPork 2013-03-11 15:29:48

+0

我的意思是隻有Grails域名。我的建議應該改變結果:即使在你的SQL語句中,我們可以看到它包含一個隱含的列「id」(除了'test_scenario_id')。 Grails總是自動添加這樣的列。重命名該列後,請檢查新的「未找到」錯誤消息。它是否包含不存在的列? – eugene82 2013-03-11 16:31:53

+0

現在說'select top 10 this_.test_exec_queue_id as test1_0_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從test_exec_queue test7_0_0_ THIS_ [42102-164]' – MorkPork 2013-03-11 17:05:52