java 合作社交易系统Myeclipse开发mysql数据库mvc结构serlvet编程计算机网页项目
一、源码特点
java 合作社交易系统是一套完善的java web信息管理系统,对理解JSP java编程开发语言有帮助,开发技术servlet+dao+bean模式开发系统具有完整的源代码和数据库,系统主要采
用B/S模式开发。开发环境为TOMCAT7.0,Myeclipse8.5开发,数据库为Mysql5.0,使用java语言开发。
java 合作社交易系统Myeclipse开发mysql数据
二、功能介绍
前台
首页浏览
网站介绍浏览
农田浏览
合作社浏览
用户注册、登录
后台
(1)合作社管理:对合作社信息进行添加、删除、修改和查看
(2)用户管理:对用户信息进行添加、删除、修改和查看
(3)网站介绍管理:对网站介绍信息进行添加、删除、修改和查看
(4)农田管理:对农田信息进行添加、删除、修改和查看
(5)入社申请管理:对入社申请信息进行添加、删除、修改和查看
(6)订单管理:对订单信息进行添加、删除、修改和查看
数据库设计
CREATE TABLE `hzs` (
`hzsid` int(11) NOT NULL auto_increment,
`hzs` VARCHAR(40) default NULL COMMENT '合作社',
`js` VARCHAR(40) default NULL COMMENT '介绍',
`lxdh` VARCHAR(40) default NULL COMMENT '联系电话',
`tp` VARCHAR(40) default NULL COMMENT '图片', PRIMARY KEY (`hzsid`)
) ENGINE=InnoDB DEFAULT CHARSET=gb2312;
CREATE TABLE `yonghu` (
`yhid` int(11) NOT NULL auto_increment,
`yhm` VARCHAR(40) default NULL COMMENT '用户名',
`mm` VARCHAR(40) default NULL COMMENT '密码',
`xm` VARCHAR(40) default NULL COMMENT '姓名',
`qx` VARCHAR(40) default NULL COMMENT '权限',
`lxdh` VARCHAR(40) default NULL COMMENT '联系电话',
`lxdz` VARCHAR(40) default NULL COMMENT '联系地址',
`hzs` VARCHAR(40) default NULL COMMENT '合作社', PRIMARY KEY (`yhid`)
) ENGINE=InnoDB DEFAULT CHARSET=gb2312;
CREATE TABLE `wzjs` (
`wzjsid` int(11) NOT NULL auto_increment,
`bt` VARCHAR(40) default NULL COMMENT '标题',
`nr` VARCHAR(40) default NULL COMMENT '内容',
`fbsj` VARCHAR(40) default NULL COMMENT '发布时间', PRIMARY KEY (`wzjsid`)
) ENGINE=InnoDB DEFAULT CHARSET=gb2312;
CREATE TABLE `nongtian` (
`ntid` int(11) NOT NULL auto_increment,
`nt` VARCHAR(40) default NULL COMMENT '农田',
`ms` VARCHAR(40) default NULL COMMENT '亩数',
`cl` VARCHAR(40) default NULL COMMENT '产量',
`js` VARCHAR(40) default NULL COMMENT '介绍',
`tp` VARCHAR(40) default NULL COMMENT '图片',
`nh` VARCHAR(40) default NULL COMMENT '农户',
`fbsj` VARCHAR(40) default NULL COMMENT '发布时间', PRIMARY KEY (`ntid`)
) ENGINE=InnoDB DEFAULT CHARSET=gb2312;
CREATE TABLE `rssq` (
`rssqid` int(11) NOT NULL auto_increment,
`bt` VARCHAR(40) default NULL COMMENT '标题',
`nr` VARCHAR(40) default NULL COMMENT '内容',
`fbsj` VARCHAR(40) default NULL COMMENT '发布时间',
`zt` VARCHAR(40) default NULL COMMENT '状态',
`yh` VARCHAR(40) default NULL COMMENT '用户',
`hf` VARCHAR(40) default NULL COMMENT '回复',
`hzs` VARCHAR(40) default NULL COMMENT '合作社', PRIMARY KEY (`rssqid`)
) ENGINE=InnoDB DEFAULT CHARSET=gb2312;
CREATE TABLE `dingdan` (
`ddid` int(11) NOT NULL auto_increment,
`ls` VARCHAR(40) default NULL COMMENT '流水',
`rq` VARCHAR(40) default NULL COMMENT '日期',
`hzs` VARCHAR(40) default NULL COMMENT '合作社',
`spsl` VARCHAR(40) default NULL COMMENT '商品数量',
`jg` VARCHAR(40) default NULL COMMENT '价格',
`zj` VARCHAR(40) default NULL COMMENT '总价',
`zt` VARCHAR(40) default NULL COMMENT '状态',
`sm` VARCHAR(40) default NULL COMMENT '说明', PRIMARY KEY (`ddid`)
) ENGINE=InnoDB DEFAULT CHARSET=gb2312;
部分代码
package com.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.bean.nongtian;
import com.dao.nongtianDao;
import java.util.List;
import java.sql.ResultSet;
public class nongtianServlet extends HttpServlet {
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("gb2312");
System.out.println("method"+request.getParameter("method"));
String method=(String)request.getParameter("method");
if(method.equals("insert")){//农田添加
insertM(request, response);
}else if(method.equals("list")){//农田列表
ListM(request, response);
}else if(method.equals("delete")){//农田删除
deleteM(request, response);
}else if(method.equals("modifyindex")){//农田修改页面
modifyIndex(request, response);
}
else if(method.equals("modify")){//农田修改
modifyM(request, response);
}else if(method.equals("detail")){//农田详细信息
detailM(request, response);
}else if(method.equals("plist")){//农田列表信息
PListM(request, response);
}
}
private void insertM(HttpServletRequest request, HttpServletResponse response){//农田添加
nongtianDao dao=new nongtianDao();
nongtian nongtian=new nongtian();
nongtian.setNtid((String)request.getParameter("keyid"));
nongtian.setNt((String)request.getParameter("nt"));
nongtian.setMs((String)request.getParameter("ms"));
nongtian.setCl((String)request.getParameter("cl"));
nongtian.setJs((String)request.getParameter("js"));
nongtian.setTp((String)request.getParameter("tp"));
nongtian.setNh((String)request.getParameter("nh"));
nongtian.setFbsj((String)request.getParameter("fbsj"));
response.setCharacterEncoding("gb2312");
try {
dao.insert(nongtian);
request.setAttribute("flag", "操作成功");
request.getRequestDispatcher("nongtian/nongtianadd.jsp").forward(request, response);
} catch (Exception e) {
e.printStackTrace();
}
}
private void ListM(HttpServletRequest request, HttpServletResponse response){//农田信息列表
ResultSet rs=null;
nongtianDao dao = new nongtianDao();
String str=(String)request.getParameter("Page");
String sql="";
response.setCharacterEncoding("gb2312");
try{
if(str==null){
str="0";
}
if(request.getSession().getAttribute("yhm")!=null){
sql+=" and nh='"+request.getSession().getAttribute("yhm")+"'";
}
rs=dao.qlist(sql);
PrintWriter out = response.getWriter();
request.setAttribute("rs", rs);
request.getRequestDispatcher("nongtian/nongtianlist.jsp?Page="+str).forward(request, response);
}catch(Exception e){
e.toString();
e.printStackTrace();
}
}
private void PListM(HttpServletRequest request, HttpServletResponse response){//测试信息列表
ResultSet rs=null;
nongtianDao dao = new nongtianDao();
System.out.println("alist");
String sql="";
response.setCharacterEncoding("gb2312");
try{
rs=dao.qlist(sql);
PrintWriter out = response.getWriter();
request.setAttribute("rs", rs);
request.getRequestDispatcher("nongtian/nongtianplist.jsp").forward(request, response);
}catch(Exception e){
e.toString();
e.printStackTrace();
}
}
private void modifyIndex(HttpServletRequest request, HttpServletResponse response){//农田修改首页
ResultSet rs=null;
response.setCharacterEncoding("gb2312");
nongtianDao dao = new nongtianDao();
String keyid=(String)request.getParameter("keyid");
String sql="";
if(keyid!=null&&!keyid.equals("")){
sql+=" and ntid='"+keyid+"'";
}
try{
rs=dao.qlist(sql);
PrintWriter out = response.getWriter();
request.setAttribute("rs", rs);
request.getRequestDispatcher("nongtian/nongtianmodify.jsp").forward(request, response);
//response.sendRedirect("nongtian/nongtianmodify.jsp");
}catch(Exception e){
e.toString();
e.printStackTrace();
}
}
private void detailM(HttpServletRequest request, HttpServletResponse response){//农田详细信息页面
ResultSet rs=null;
response.setCharacterEncoding("gb2312");
nongtianDao dao = new nongtianDao();
String keyid=(String)request.getParameter("keyid");
String sql="";
if(keyid!=null&&!keyid.equals("")){
sql+=" and ntid='"+keyid+"'";
}
try{
rs=dao.qlist(sql);
request.setAttribute("rs", rs);
request.getRequestDispatcher("nongtian/nongtiandetail.jsp").forward(request, response);
}catch(Exception e){
e.toString();
e.printStackTrace();
}
}
private void deleteM(HttpServletRequest request, HttpServletResponse response){//农田删除
ResultSet lst=null;
nongtianDao dao = new nongtianDao();
response.setCharacterEncoding("gb2312");
String keyid=(String)request.getParameter("keyid");
try{
dao.delete(keyid);
request.setAttribute("flag", "删除成功");
request.getRequestDispatcher("nongtianServlet?method=list").forward(request, response);
//response.sendRedirect("nongtianServlet?method=list");
}catch(Exception e){
e.toString();
e.printStackTrace();
}
}
private void modifyM(HttpServletRequest request, HttpServletResponse response){//农田修改功能
nongtianDao dao=new nongtianDao();
nongtian nongtian=new nongtian();
nongtian.setNtid((String)request.getParameter("keyid"));
nongtian.setNt((String)request.getParameter("nt"));
nongtian.setMs((String)request.getParameter("ms"));
nongtian.setCl((String)request.getParameter("cl"));
nongtian.setJs((String)request.getParameter("js"));
nongtian.setTp((String)request.getParameter("tp"));
nongtian.setNh((String)request.getParameter("nh"));
nongtian.setFbsj((String)request.getParameter("fbsj"));
response.setCharacterEncoding("gb2312");
try {
dao.modify(nongtian);
PrintWriter out = response.getWriter();
request.setAttribute("flag", "操作成功");
request.getRequestDispatcher("nongtianServlet?method=list").forward(request, response);
//response.sendRedirect("nongtianServlet?method=list");
} catch (Exception e) {
e.printStackTrace();
}
}
}
三、注意事项
1、管理员账号:admin密码:admin 数据库配置文件DBO.java
2、开发环境为TOMCAT7.0,Myeclipse8.5开发,数据库为Mysql5.0,使用java语言开发。开发技术servlet+dao+bean模式开发
3、数据库文件名是jspjsphxyjiaoyi.sql ,系统名称hxyjiaoyi
4、系统首页地址:http://127.0.0.1:8080/jsphxyjiaoyi/qt/
四、系统实现