package com.sf.jdbc.j20250906;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;

/**
 * @author WanJl
 * @version 1.0
 * @title Account_select
 * @description
 * @create 2025/9/6
 */
public class Account_select {
    private static String url="jdbc:mysql://127.0.0.1:3306/db03";
    private static String username="root";
    private static String password="123456";
    public static void main(String[] args) throws Exception{
        ArrayList<Account> list=new ArrayList<>();
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection conn = DriverManager.getConnection(url, username, password);
        Statement stat = conn.createStatement();
        String sql="SELECT * FROM account";
        ResultSet rs = stat.executeQuery(sql);
        while (rs.next()){
            int id = rs.getInt("id");
            String name = rs.getString("name");
            double money = rs.getDouble("money");
            Account account=new Account();
            account.setId(id);
            account.setName(name);
            account.setMoney(money);
            list.add(account);

            ;
        }
        System.out.println(list);
    }
}
