关于struts+hibernate+spring的问题~~~~~~~~~~~~~~~~~!帮忙解决一下啊,谢谢了!
我用myEclipse做了struts+hibernate+spring一个简单的例子,但是一运行就说无法建立连接。
错误 如下:
Hibernate operation: Cannot open connection; uncategorized SQLException for SQL [???]; SQL
state [null]; error code [0]; Cannot createJDBC driver of class
'com.microsoft.jdbc.sqlserver.SQLServerDriver ' for connect URL '
jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=spring '; nested exception is
org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class
'com.microsoft.jdbc.sqlserver.SQLServerDriver ' for connect URL '
jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=spring
我的applicationContext.xml文件如下:
<?xml version= "1.0 " encoding= "UTF-8 "?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN " "http://www.springframework.org/dtd/spring
-beans.dtd ">
<beans>
<bean id= "springbean "
class= "org.apache.commons.dbcp.BasicDataSource ">
<property name= "driverClassName ">
<value> com.microsoft.jdbc.sqlserver.SQLServerDriver </value>
</property>
<property name= "url ">
<value>
jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=spring
</value>
</property>
<property name= "username ">
<value> sa </value>
</property>
<property name= "password ">
<value> 1234 </value>
</property>
</bean>
<bean id= "sf "
class= "org.springframework.orm.hibernate3.LocalSessionFactoryBean ">
<property name= "dataSource ">
<ref bean= "springbean " />
</property>
<property name= "hibernateProperties ">
<props>
<prop key= "hibernate.dialect ">
org.hibernate.dialect.SQLServerDialect
</prop>
</props>
</property>
<property name= "mappingResources ">
<list>
<value> po/Student.hbm.xml </value>
</list>
</property>
</bean>
<bean name= "sel " class= "dao.dao ">
<property name= "factory ">
<ref bean= "sf " />
</property>
</bean>
<bean name= "/spring " class= "action.SpringAction ">
<property name= "i ">
<ref bean= "sel " />
</property>
</bean>
</beans>
请大家帮忙看啊,郁闷好几天了,也解决不了这个问题!
[解决办法]
哥们,我也碰到过这个问题,也是烦了我几天,你在确保你的包,用户名,密码等等都正确的情况下,把:
<value> jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=spring </value>
写成一行!!一行啊~~~~~~~
如果写成
<value>
jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=spring
</value>
这样,就会报错。