码迷,mamicode.com
首页 > 其他好文 > 详细

期中测试---人口普查dao层代码

时间:2020-12-19 13:35:10      阅读:5      评论:0      收藏:0      [点我收藏+]

标签:span   import   color   imp   pre   print   public   oid   mysql   

Billdao

package util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class DBUtil {
    public static String db_url = "jdbc:mysql://localhost:3306/qizhongce?useSSL=false";
    public static String db_user = "root";//账号
    public static String db_pass = "258000";//密码

    public static Connection getConn () {
        Connection conn = null;

        try {
            Class.forName("com.mysql.jdbc.Driver");
            conn = DriverManager.getConnection(db_url, db_user, db_pass);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return conn;
    }


    public static void close (Statement state, Connection conn) {
        if (state != null) {
            try {
                state.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

        if (conn != null) {
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

    public static void close (ResultSet rs, Statement state, Connection conn) {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

        if (state != null) {
            try {
                state.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

        if (conn != null) {
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

}

Bill

package dao;

public class Bill {
    private String gender;
    private String house;
    private String idcard;
    private String sqare;
    private String jian;
    private String owname;
    private String sex;
    private String zu;
    private String address;



    public String getIdcard() {
        return idcard;
    }

    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }

    public String getSqare() {
        return sqare;
    }

    public void setSqare(String sqare) {
        this.sqare = sqare;
    }

    public String getJian() {
        return jian;
    }

    public void setJian(String jian) {
        this.jian = jian;
    }

    public String getOwname() {
        return owname;
    }

    public void setOwname(String owname) {
        this.owname = owname;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getZu() {
        return zu;
    }

    public void setZu(String zu) {
        this.zu = zu;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }


    public String getHouse() {
        return house;
    }

    public void setHouse(String house) {
        this.house = house;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public Bill(String gender, String house, String sqare, String jian, String owname, String idcard,String sex,
                String zu, String address) {
        this.gender = gender;
        this.house = house;
        this.sqare = sqare;
        this.jian = jian;
        this.owname = owname;
        this.idcard = idcard;
        this.sex = sex;
        this.zu = zu;
        this.address = address;
    }
}

 

期中测试---人口普查dao层代码

标签:span   import   color   imp   pre   print   public   oid   mysql   

原文地址:https://www.cnblogs.com/linmob/p/14139466.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!