package com.sf.jdbc.j20250906;

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

/**
 * @author WanJl
 * @version 1.0
 * @title Account_Insert
 * @description
 * @create 2025/9/6
 */
public class Account_Insert {
    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{
        Class.forName("com.mysql.cj.jdbc.Driver");

        Connection conn = DriverManager.getConnection(url, username, password);

        Statement stat = conn.createStatement();
        Account account=new Account(4,"赵六",10000);

        String sql="INSERT INTO account VALUES ("
                +account.getId()+",'"+account.getName()+"',"+account.getMoney()+")";
        //因为是新增数据insert into。所以使用executeUpdate()方法。
        int count = stat.executeUpdate(sql);

        System.out.printf("新增了%d条记录\n",count);


    }
}
