首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

spring使用dbcp类型的DataSource,数据库为mysql,老报异常: org.apache.commons.dbcp.SQLNestedExcep

2014-01-26 
spring的配置文件为:beansbean iddataSourceclassorg.apache.commons.dbcp.BasicDataSourcedestro

spring的配置文件为:
  <beans>
  <bean id="dataSource"
  class="org.apache.commons.dbcp.BasicDataSource"
  destroy-method="close">
  <property name="driverClassName">
  <value>com.mysql.jdbc.Driver</value>
  </property>
  <property name="url">
  <value>
  jdbc:mysql://localhost:3306/test
  </value>
  </property>
  <property name="username">
  <value>root</value>
  </property>
  <property name="password">
  <value>123</value>
  </property>
  </bean>
  <bean id="sessionFactory"
  class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  <property name="dataSource">
  <ref local="dataSource" />
  </property>
  <property name="mappingResources">
  <list>
  <value>com/gyf/hibernate/UserBasicinfo.hbm.xml</value>
  <value>com/gyf/hibernate/UserStateinfo.hbm.xml</value>
  </list>
  </property>
  <property name="hibernateProperties">
  <props>
  <prop key="hibernate.dialect">
  org.hibernate.dialect.MySQLDialect
  </prop>
  <prop key="hibernate.show_sql">
  true
  </prop>
  </props>
  </property>
  </bean>
  <bean id="transactionManager"
  class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  <property name="sessionFactory">
  <ref local="sessionFactory" />
  </property>
  </bean>
  <bean id="userDAO" class="com.gyf.dao.UserDAO">
  <property name="sessionFactory">
  <ref local="sessionFactory" />
  </property>
  </bean>
  <bean id="userDAOProxy"
  class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
  <property name="transactionManager">
  <ref bean="transactionManager" />
  </property>
  <property name="target">
  <ref local="userDAO" />
  </property>
  <property name="transactionAttributes">
  <props>
  <prop key="insert*">PROPAGATION_REQUIRED</prop>
  <prop key="get*">
  PROPAGATION_REQUIRED,readOnly
  </prop>
  </props>
 
  </property>
  </bean>
  </beans>
  ------------------
  可我现在什么都配置好了,但运行测试代码报错:
  2005-10-18 15:47:30,882 INFO (ConnectionProviderFactory.java:53) - Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider
  2005-10-18 15:47:30,929 DEBUG (JDBCExceptionReporter.java:63) - SQL Exception
  org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'com.mysql.jdbc.Driver' for connect URL '
  jdbc:mysql://localhost:3306/test
  '         

热点排行