2

我正在按照下面的教程进行操作,但必须有一些重要的步骤来假设我没有的知识。

http://padcom13.blogspot.co.uk/2011/01/setting-up-sql-server-2008-express-to.html

以下是我的 datasource.groovy 中的设置

username = "sa"
password = ""
url = "jdbc:sqlserver://localhost:1433;databaseName=Sandpit"
driverClassName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
dialect = "org.hibernate.dialect.SQLServerDialect"

以下是运行应用命令时弹出的错误

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 'com.microsoft.sqlserver.jdbc.SQLServerDriver'
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 'com.microsoft.sqlserver.jdbc.SQLServerDriver'

这几天一直在做这件事而没有看到我的应用程序运行......有什么建议吗?

4

2 回答 2

4

根本原因是Cannot load JDBC driver class 'com.microsoft.sqlserver.jdbc.SQLServerDriver'

那是因为类路径中缺少您的驱动程序。对于 SQL Server,您需要将 jar 复制到 lib 文件夹。

在其他情况下,如 MySQL,您可以声明为 maven 依赖项。

于 2013-01-25T13:51:44.347 回答
0

我们正在做和你一样的事情。因此,我们的 /lib 目录中有 sqljdbc.jar。

在我们的 DataSource.groovy 中,我们有:

dbCreate = "update" // one of 'create', 'create-drop','update'
username = "dbo"
driverClassName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
url = "jdbc:sqlserver://devdb02:1433;databaseName=my_database;"

I remember that just the .jar is not enough, I think you need to install a small part into your windows/unix-directory e.g. from here:

http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11774

(that's also needed if you maybe use PHP with MSSQL)

于 2013-01-25T14:10:12.383 回答