Spring整和Hibernate与c0p3经验

java.sql.SQLException: No suitable driver
     at java.sql.DriverManager.getDriver(Unknown Source)
     at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:223)
     at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)
     at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
     at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
     at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
     at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
     at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
     at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
     at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)

   1.  <bean id="dataSource" 
   2.         class="org.apache.commons.dbcp.BasicDataSource">  
   3.         <property name="driverClassName">  
   4.             <value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>  
   5.         </property>  
   6.         <property name="url">  
   7.             <value>  
   8. jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=hiber;SelectMethod=cursor  
   9. </value>     //就是这里的换行惹的祸  
  10.         </property>  
  11.         <property name="username">  
  12.             <value>sa</value>  
  13.         </property>  
  14.         <property name="password">  
  15.             <value></value>  
  16.         </property>  
  17.     </bean> 

改动后
java 代码

   1. <bean id="dataSource" 
   2.         class="org.apache.commons.dbcp.BasicDataSource">  
   3.         <property name="driverClassName">  
   4.             <value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>  
   5.         </property>  
   6.         <property name="url">  
   7.             <value>jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=hiber;SelectMethod=cursor</value>    //要写在一行千万不要换行
   8.         </property>  
   9.         <property name="username">  
  10.             <value>sa</value>  
  11.         </property>  
  12.         <property name="password">  
  13.             <value></value>  
  14.         </property>  
  15.     </bean> 

你可能感兴趣的:(java,spring,Hibernate,jdbc,Microsoft)