Postgresql数据库javaweb教程详细完整版(一)

本文介绍了一个基于PostgreSQL数据库的Java Web应用程序的开发过程,采用MVC架构。主要内容包括模型层的YqcsLsy类定义,控制层的YqcsLsyDao接口及其实现,逻辑层使用原生Servlet处理请求,以及如何实现Excel导出功能。教程以yqcs_lsy数据表为例,展示了基本的数据库操作,并预告了后续章节将涉及的前端开发和其他业务功能。
摘要由CSDN通过智能技术生成

后台数据库以yqcs_lsy为例:数据表如下(表中字段较多,未能展示完全)

采用MVC结构进行开发:

本文的写作环境在数据库可以连接之后

1.模型层

新建类YqcsLsy,没多少好说的,就是常规的变量定义,构造函数和get,set方法,含有参数的构造函数会在以后的业务中调用

public class YqcsLsy {
	private Integer id;
	private String name;
	private String type;
	private Double width;
	private Double bottom;
	private Double top;
	private Double height;
	private String pile;
	private Double wheelbase;
	private Double elevation;
	private String location;
	private Double groovewidth;
	private Double grooveheight;
	private Date date;
	private String tip;
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public Double getWidth() {
		return width;
	}
	public void setWidth(Double width) {
		this.width = width;
	}
	public Double getBottom() {
		return bottom;
	}
	public void setBottom(Double bottom) {
		this.bottom = bottom;
	}
	public Double getTop() {
		return top;
	}
	public void setTop(Double top) {
		this.top = top;
	}
	public Double getHeight() {
		return height;
	}
	public void setHeight(Double height) {
		this.height = height;
	}
	public String getPile() {
		return pile;
	}
	public void setPile(String pile) {
		this.pile = pile;
	}
	public Double getWheelbase() {
		return wheelbase;
	}
	public void setWheelbase(Double wheelbase) {
		this.wheelbase = wheelbase;
	}
	public Double getElevation() {
		return elevation;
	}
	public void setElevation(Double elevation) {
		this.elevation = elevation;
	}
	public String getLocation() {
		return location;
	}
	public void setLocation(String location) {
		this.location = location;
	}
	public Double getGroovewidth() {
		return groovewidth;
	}
	public void setGroovewidth(Double groovewidth) {
		this.groovewidth = groovewidth;
	}
	public Double getGrooveheight() {
		return grooveheight;
	}
	public void setGrooveheight(Double grooveheight) {
		this.grooveheight = grooveheight;
	}
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	public String getTip() {
		return tip;
	}
	public void setTip(String tip) {
		this.tip = tip;
	}
	public YqcsLsy(Integer id, String name, String type, Double width, Double bottom, Double top, Double height,
			String pile, Double wheelbase, Double elevation, String location, Double groovewidth, Double grooveheight,
			Date date, String tip) {
		super();
		this.id = id;
		this.name = name;
		this.type = type;
		this.width = width;
		this.bottom = bottom;
		this.top = top;
		this.height = height;
		this.pile = pile;
		this.wheelbase = wheelbase;
		this.elevation = elevation;
		this.location = location;
		this.groovewidth = groovewidth;
		this.grooveheight = grooveheight;
		this.date = date;
		this.tip = tip;
	}
	public YqcsLsy(String name, String type, Double width, Double bottom, Double top, Double height, String pile,
			Double wheelbase, Double elevation, String location, Double groovewidth, Double grooveheight, Date date,
			String tip) {
		super();
		this.name = name;
		this.type = type;
		this.width = width;
		this.bottom = bottom;
		this.top = top;
		this.height = height;
		this.pile = pile;
		this.wheelbase = wheelbase;
		this.elevation = elevation;
		this.location = location;
		this.groovewidth = groovewidth;
		this.grooveheight = grooveheight;
		this.date = date;
		this.tip = tip;
		
	}
	@Override
	public String toString() {
		return "YqcsLsy [id=" + id + ", name=" + name + ", type=" + type + ", width=" + width + ", bottom=" + bottom
				+ ", top=" + top + ", height=" + height + ", pile=" + pile + ", wheelbase=" + wheelbase + ", elevation="
				+ elevation + ", location=" + location + ", groovewidth=" + groovewidth + ", grooveheight="
				+ grooveheight + ", date=" + date + ", tip=" + tip + "]";
	}
	
	public YqcsLsy() {
		
	}
	
	
	//分页查询
	private int pageNo;
	public int getPageNo() {
		return pageNo;
	}
	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}
	//根据名称分页查询
	public YqcsLsy(String name,int pageNo){
		this.name=name;
		this.pageNo=pageNo;
		
	}

}

2.控制层(写sql语句,获取数据库的数据)

对于仪器参数,目前只要做这一些最基本的操作

YqcsLsyDao层结构

public interface YqcsLsyDao {
	//前台通过下拉列表查询数据用
	public List<YqcsLsy> getLsyByName(String name);
	//获取下拉列表里的数据
	public List<YqcsLsy> getAllName();
	//查询结果分页显示
	public List<YqcsLsy> getPageList(YqcsLsy yqcsLsy,
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值