Javafx之网格布局,下拉框,单(多)选框

这篇博客主要介绍了如何使用JavaFX进行界面设计,包括网格布局的运用,以及下拉框和单选框的实现。同时,文章还涵盖了数据库操作,讲解了连接SQL Server数据库的帮助类、实体类的设计、Dao类的实现,并通过测试类展示了登录和注册的功能。
摘要由CSDN通过智能技术生成

一、连接数据库 帮助类

package com.zking.util;

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

/**
 * 连接数据库 帮助类
 * @author Administrator
 *
 */
public class DBHelper {
	//注册驱动
	static {
		try {
			Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
		} catch (Exception e) {
			e.printStackTrace();//处理异常信息
		}
	}
	
	//连接语句
	private static final String url = "jdbc:sqlserver://sqlserver:1433;DatabaseName=T283";
	//获得连接
	public static Connection getCon() {
		Connection con = null;
		try {
			con = DriverManager.getConnection(url,"sa","123");
		} catch (Exception e) {
			e.printStackTrace();//处理异常信息
		}
		return con;
	}
	
	public static void close(Connection con,PreparedStatement ps,ResultSet rs) {
		try {
			if(con!=null) {
				con.close();
			}
			if(ps!=null) {
				ps.close();
			}
			if(rs!=null) {
				rs.close();
			}
		} catch (Exception e) {
			e.printStackTrace();//处理异常信息
		}
	}
}

二、实体类 

package com.zking.entity;

/**
 * 学生 实体类
 * 定义属性
 * @author Administrator
 *
 */
public class Student {
	//定义属性,私有化属性
	private int id;
	private String name;
	private String password;
	private String sex;
	//封装
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getSex() {
		return sex;
	}
	public void setSex(String sex) {
		this.sex = sex;
	}
	
	//构造函数
	public Student() {
		super();
	}
	public Student(int id, String name, String password, String sex) {
		super();
		this.id = id;
		this.name = name;
		this.password = password;
		this.sex = s
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

youdabi

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值