• 1月4日 家庭小账本开发记录


    1、数据库建表

    2、实体类层

    package com.edu.entity;

    import java.util.Date;

    public class User {
    private int id;
    private String username;
    private String userused;
    private String usermoney;
    private Date usedate;
    public int getId() {
    return id;
    }
    public void setId(int id) {
    this.id = id;
    }
    public String getUsername() {
    return username;
    }
    public void setUsername(String username) {
    this.username = username;
    }
    public String getUserused() {
    return userused;
    }
    public void setUserused(String userused) {
    this.userused = userused;
    }
    public String getUsermoney() {
    return usermoney;
    }
    public void setUsermoney(String usermoney) {
    this.usermoney = usermoney;
    }
    public Date getUsedate() {
    return usedate;
    }
    public void setUsedate(Date usedate) {
    this.usedate = usedate;
    }
    public User(int id, String username, String userused, String usermoney, Date usedate) {
    super();
    this.id = id;
    this.username = username;
    this.userused = userused;
    this.usermoney = usermoney;
    this.usedate = usedate;
    }
    public User() {
    // TODO 自动生成的构造函数存根
    }

    }

    3、数据库连接驱动

    package com.edu.entity;

    import java.sql.Connection;

    import java.sql.DriverManager;

    public class DbHelper {

    private static String url = "jdbc:mysql://localhost:3306/countuser"; // 数据库地址

    private static String userName = "root"; // 数据库用户名

    private static String passWord = "*****"; // 数据库密码

    private static Connection conn = null;

    private DbHelper() {

    }

    public static Connection getConnection() {

    if (null == conn) {

    try {

    Class.forName("com.mysql.jdbc.Driver");

    conn = DriverManager.getConnection(url, userName, passWord);

    } catch (Exception e) {

    e.printStackTrace();

    }

    }

    return conn;

    }

    public static void main(String[] args) { // 测试数据库是否连通

    System.err.println(getConnection());

    }

    }

    4、观看JSP+Servlet+MySql+Tomcat+JDBC项目详细讲解视频

  • 相关阅读:
    day12-html(css)
    day-12- 前端 html
    python-day11 pymysql
    day11-mysql 练习题
    python-day11 Mysql 数据类操作
    python-day11 Mysql 数据类型
    python-day11-MYSQL 数据库及数据表
    最简单的checkbox, radio跟文字在一行
    前端压缩
    table td 设置宽高无效的问题
  • 原文地址:https://www.cnblogs.com/lx06/p/14276077.html
Copyright © 2020-2023  润新知