日期:2014-05-16  浏览次数:20536 次

spring jdbcTemplate使用

(1)springJdbcContext.xml

Java代码 复制代码
  1. <?xml?version="1.0"?encoding="UTF-8"?> ??
  2. <beans?xmlns="http://www.springframework.org/schema/beans"? ??
  3. ????xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"? ??
  4. ????xmlns:context="http://www.springframework.org/schema/context"? ??
  5. ????xmlns:aop="http://www.springframework.org/schema/aop"? ??
  6. ????xmlns:tx="http://www.springframework.org/schema/tx"? ??
  7. ????xsi:schemaLocation="http://www.springframework.org/schema/beans?http://www.springframework.org/schema/beans/spring-beans-2.5.xsd? ??
  8. ????http://www.springframework.org/schema/context?http://www.springframework.org/schema/context/spring-context-2.5.xsd? ??
  9. ????http://www.springframework.org/schema/tx?http://www.springframework.org/schema/tx/spring-tx-2.5.xsd? ??
  10. ????http://www.springframework.org/schema/aop?http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"> ??
  11. ??
  12. ????<description>springApp</description>???? ??
  13. ????<!--?dataSource?for?MySQL?--> ??
  14. ????<bean?id="dataSource"??
  15. ????????class="org.apache.commons.dbcp.BasicDataSource"??
  16. ????????destroy-method="close"> ??
  17. ????????<property?name="driverClassName"??
  18. ????????????value="com.mysql.jdbc.Driver"?/> ??
  19. ????????<property?name="url"??
  20. ????????????value="jdbc:mysql://localhost:3306/springapp"?/> ??
  21. ????????<property?name="username"?value="root"?/> ??
  22. ????????<property?name="password"?value=