无法加载JDBC驱动程序类“net.sourceforge.jtds.jdbc.Driver”编译G

2019-07-21 05:01发布

这是我的第一篇,所以要温柔! :)

我已经成立了一个Grails项目(在Grails的太相当新的),并在尝试将其连接到一个SQL 2008数据库,我已经添加了JTDS-1.3.0.jar到lib文件夹,我的构建路径,和然后,我改变了我的DataSource.groovy文件中,内容如下: -

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

| 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'

Answer 1:

我有过类似的问题。

我已经改变了JTDS的版本1.2.6和一切工作正常。

顺便说一句 - 你不需要手动添加的罐子。 你只需要以下添加到您的BuildConfig.groovy (相关内容部分):

runtime 'net.sourceforge.jtds:jtds:1.2.6'


文章来源: Cannot load JDBC driver class 'net.sourceforge.jtds.jdbc.Driver' when compiling Grails project