spring jdbc 连接数据库提示Cannot load JDBC driver class
springjdbc连接数据库,报如下错误Exceptioninthread"main"org.springframework.jdbc.CannotGetJdbcCon...
spring jdbc连接数据库,报如下错误
Exception in thread "main" org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.microsoft.jdbc.sqlserver.SQLServerDriver'
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:573)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:812)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:868)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:876)
at queryresults.cqlandun.info.impl.ResultsDaoImpl.addResults(ResultsDaoImpl.java:41)
at queryresults.cqlandun.info.test.TextJdbcTemplate.main(TextJdbcTemplate.java:32)
数据库是sqlserver2008,jar包用的是sqljdbc3.2
bean:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" >
<property name="driverClassName" value = "com.microsoft.jdbc.sqlserver.SQLServerDriver" />
<property name="url" value = "jdbc:sqlserver://localhost:1433;DatabaseName=queryresults" />
<property name="username" value = "sa" />
<property name="password" value = "saa" />
</bean>
不知道为何会报这个错,求高手解答,复制粘贴党就不要来了,3Q!
<property name="driverClassName" value = "com.microsoft.jdbc.sqlserver.SQLServerDriver" />
写反了,应该是com.microsoft.sqlserver.jdbc.SQLServerDriver我了个大去! 展开
Exception in thread "main" org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.microsoft.jdbc.sqlserver.SQLServerDriver'
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:573)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:812)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:868)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:876)
at queryresults.cqlandun.info.impl.ResultsDaoImpl.addResults(ResultsDaoImpl.java:41)
at queryresults.cqlandun.info.test.TextJdbcTemplate.main(TextJdbcTemplate.java:32)
数据库是sqlserver2008,jar包用的是sqljdbc3.2
bean:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" >
<property name="driverClassName" value = "com.microsoft.jdbc.sqlserver.SQLServerDriver" />
<property name="url" value = "jdbc:sqlserver://localhost:1433;DatabaseName=queryresults" />
<property name="username" value = "sa" />
<property name="password" value = "saa" />
</bean>
不知道为何会报这个错,求高手解答,复制粘贴党就不要来了,3Q!
<property name="driverClassName" value = "com.microsoft.jdbc.sqlserver.SQLServerDriver" />
写反了,应该是com.microsoft.sqlserver.jdbc.SQLServerDriver我了个大去! 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询