问题描述
这是我的第一篇文章,所以要温柔! :)
This is my first post so be gentle! :)
我设置了一个grails项目(在grails中相当新),并尝试将其连接到SQL 2008数据库,我已经添加了jtds -1.3.0.jar到lib文件夹和我的构建路径,然后我改变了我的DataSource.groovy文件,如下所示: -
I've set up a grails project (fairly new at grails too) and am attempting to connect it to a SQL 2008 database, I've added the jtds-1.3.0.jar to the lib folder and to my build path, and then I've altered my DataSource.groovy file to read as follows: -
dataSource {
pooled = true
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://TestServer:1433;databaseName=TestTable"
username = "test"
password = "test"
// logSql=true
}
}
麻烦的是当我尝试编译我得到一个巨大的错误, ,我失踪了什么?我已经google了,但找不到一个明显的解决方案...:S
Trouble is when I try to compile I get a massive error which reads as follows, what am I missing? I've googled about but can't find an obvious solution... :S
| Error 2013-03-08 12:44:33,451 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error executing bootstraps: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'net.sourceforge.jtds.jdbc.Driver'
Message: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'net.sourceforge.jtds.jdbc.Driver'
推荐答案
我在过去也有类似的问题。
I have had similar problems in the past.
我已将JTDS的版本更改为1.2.6,并且都正常。
I've changed the version of JTDS to 1.2.6 and all works fine.
- 您不需要手动添加该jar。您只需将以下内容添加到 BuildConfig.groovy
(在依赖关系部分):
By the way - you don't need to add the jar manually. You just have to add the following to your BuildConfig.groovy
(in the dependencies section):
runtime 'net.sourceforge.jtds:jtds:1.2.6'
这篇关于在编译Grails项目时,无法加载JDBC驱动程序类'net.sourceforge.jtds.jdbc.Driver'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!