Source Schema : swing_atm
Target Server Type : MySQL
Target Server Version : 80013
File Encoding : 65001
Date: 11/07/2021 22:04:12
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
– Table structure for account
DROP TABLE IF EXISTS account
;
CREATE TABLE account
(
accountNo
int(11) NOT NULL,
pwd
int(1) NOT NULL,
aName
varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
balance
double(255, 2) NULL DEFAULT NULL,
PRIMARY KEY (accountNo
) USING BTREE
) ENGINE = InnoDB CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic;
– Records of account
INSERT INTO account
VALUES (1, 1, ‘张三’, 99.00);
INSERT INTO account
VALUES (2, 2, ‘李四’, 346.00);
SET FOREIGN_KEY_CHECKS = 1;
5.工程截图
二、系统展示
======
1.注册页面
2.登录页面
3.主页面
4.取款
5.存款
6.转账
7.余额查询
三、部分代码
======
AccountDAO.java
package dao;
import java.sql.ResultSet;
import db.DBUtil;
import entity.Account;
public class AccountDAO {
public Account accountDao(int accountNo) {
return findAccByNo(accountNo);
}
// 如果用户找不到,返回false
public boolean accountDaoForUI(int accountNo) {
if (findAccByNo(accountNo) != null)
return true;
else
return false;
}
// 根据账户查询用户,并返回一个Account对象
public Account findAccByNo(int accountNo) {
DBUtil db = new DBUtil();
Account account = null;
try {
// 获取数据库连接
db.getConnection();
// 使用PreparedStatement发送sql语句
String sql = “SELECT * FROM account WHERE accountNo=?”;
// 设置参数
Object[] param = new Object[] { accountNo };
// 执行查询
ResultSet rs = db.executeQuery(sql, param);
if (rs.next()) {
// 将结果集中的数据封装到对象中
account = new Account(rs.getInt(1), rs.getInt(2), rs