• 关于DAO
    DAO组件是整个java应用的吃就成访问的重要组件,Dao模式的主要内容为:应用中所有对数据库的访问都通过Dao组件完成,Dao组件封装了对数据库的增、删、改、查等操作。

  • 具体实现

  1. 创建一个新的项目地址,名称为Spring

  2. 既然是数据库操作,肯定要有数据库配置,创建一个jdbc.properties的文件,放置在src/目录下,里面包含数据库连接的重要信息。


    1. jdbc.driverClassName=com.mysql.jdbc.Driver  

    2. jdbc.url = jdbc:mysql://127.0.0.1:3306/test  

    3. jdbc.username = root  

    4. jdbc.password = root  




  3. 创建一个bean.xml


    1. <?xml version="1.0" encoding="UTF-8"?>  

    2. <beans    

    3.    xmlns="http://www.springframework.org/schema/beans"    

    4.    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    

    5.    xmlns:context="http://www.springframework.org/schema/context"  

    6.    xmlns:aop="http://www.springframework.org/schema/aop"  

    7.    xmlns:tx="http://www.springframework.org/schema/tx"  

    8.    xsi:schemaLocation="http://www.springframework.org/schema/beans  

    9.    http://www.springframework.org/schema/beans/spring-beans-2.0.xsd  

    10.    http://www.springframework.org/schema/context  

    11.    http://www.springframework.org/schema/context/spring-context-2.5.xsd  

    12.    http://www.springframework.org/schema/aop  

    13. java教程,自学编程,青软培训