编译 Grails 项目时无法加载 JDBC 驱动程序类“net.sourceforge.jtds.jdbc.Driver" [英] Cannot load JDBC driver class 'net.sourceforge.jtds.jdbc.Driver' when compiling Grails project

查看:34
本文介绍了编译 Grails 项目时无法加载 JDBC 驱动程序类“net.sourceforge.jtds.jdbc.Driver"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

问题是当我尝试编译时出现了一个大错误,内容如下,我错过了什么?我用谷歌搜索但找不到明显的解决方案......: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"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆