ImageVerifierCode 换一换
格式:DOCX , 页数:114 ,大小:25.97KB ,
资源ID:7321776      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/7321776.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(java+数据库教室管理系统代码.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

java+数据库教室管理系统代码.docx

1、java+数据库教室管理系统代码 1. 创建数据库Create datebase classManager;create table ClassInfo(教室编号教室设备varchar(10) primary key,varchar(100) not null,教室容纳人数int not null,教室管理员编号varchar(10) not null);create table TeacherInfo(教师编号教师姓名教授课程教师职称varchar(10) primary key,varchar(20) not null,varchar(50),varchar(20) not null);c

2、reate table ClassRoomInfo(教室编号varchar(10),上课开始时间dateTime not null,dateTime not null,结束时间教师编号varchar(10),Foreign key (教室编号 ) references ClassInfo(教室编号 ),Foreign key (教师编号 ) references TeacherInfo(教师编号 );create table manager(username varchar(10) not null,userpsw varchar(10) not null);向其中插入数据。2.创建登录界面p

3、ackage dev.chall.otherinterface;import java.awt.Cursor;import java.awt.FlowLayout;import java.awt.Frame; import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowEvent;import java.sql.Connection;import java.sql.DriverManager;import

4、 java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import javax.swing.JButton;import javax.swing.JDialog;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JTextField;public class Login extends JDialog implements A

5、ctionListenerprivate JLabel name;private JLabel psw;private JTextField nameV;private JPasswordField pswV;private JButton login,quit;private JPanel top;private JPanel center;private JPanel bottom;private JLabel prompt;public static String loginName;public Login(Frame owner, String title, boolean moda

6、l) super(owner, title, modal);init();private void init()name=new JLabel(登录名 :);nameV=new JTextField(10); top=new JPanel();top.add(name);top.add(nameV);this.add(top);psw=new JLabel(密码 :);pswV=new JPasswordField(10);center=new JPanel();center.add(psw);center.add(pswV);this.add(center);login=new JButto

7、n();login.setText(登录 );login.setActionCommand(login);login.addActionListener(this);quit=new JButton(退出 );quit.setActionCommand(quit);quit.addActionListener(this);bottom=new JPanel();bottom.add(login);bottom.add(quit);this.add(bottom);prompt=new JLabel();this.add(prompt);this.setLayout(new GridLayout

8、(4, 1);this.setLocation(550, 230);this.setSize(200,200);this.setVisible(true);Overridepublic void actionPerformed(ActionEvent arg0) if(arg0.getActionCommand()=login)String name=nameV.getText();String psw=pswV .getText(); if(name.length()=0|psw.length()=0)prompt.setText(提示:用户名或密码为空!);return;if(checkC

9、ount(name,psw)this.dispose();elseprompt.setText(提示:用户名或密码错误!);return;else if(arg0.getActionCommand()=quit)System.exit(0);private boolean checkCount(String name,String psw)Connection connection=null;PreparedStatement ps=null;ResultSet rs=null;try / 加载驱动Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);/ 得到

10、连接connection=DriverManager.getConnection(jdbc:odbc:classManager,sa,songchao);/创建访问数据库接口ps=connection.prepareStatement(select * from manager);rs=ps.executeQuery();while(rs.next() String namet=rs.getString(1);String pswt=rs.getString(2);System.out.println(namet+pswt+-+name+psw+-);if(namet.equals(name)

11、&pswt.equals(psw)loginName=namet;return true;System.out.println(false); catch (Exception e) e.printStackTrace();finallytry rs.close();ps.close();connection.close(); catch (SQLException e) e.printStackTrace();return false;Overrideprotected void processWindowEvent(WindowEvent arg0) super.processWindow

12、Event(arg0);if(arg0.getID()=WindowEvent.WINDOW_CLOSING)System.exit(0);3.实现主界面,实现各按钮的作用package dev.chall.main; import java.awt.BorderLayout;import java.awt.FlowLayout;import java.awt.Font;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt

13、.event.ItemEvent;import java.awt.event.ItemListener;import java.awt.event.WindowEvent;import java.util.Iterator;import java.util.Vector;import javax.swing.JButton;import javax.swing.JComboBox;import javax.swing.JDialog;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;imp

14、ort javax.swing.JScrollBar;import javax.swing.JScrollPane;import javax.swing.JTable;import javax.swing.JTextField;import dev.chall.otherinterface.Delete;import dev.chall.otherinterface.Insert;import dev.chall.otherinterface.Update;import dev.chall.otherinterface.Login;import dev.chall.otherinterface

15、.RemindDialog;import dev.chall.util.MyTableModel;public class ControlInterface extends JFrame implements ActionListener/ 登录界面Login login;/主控制界面private JPanel/topBartopBar,rightBar;userName;private JLabel private JButton/rightBarquit;private JPanelprivate JLabelprivate JComboBoxprivate JButtonoperati

16、onP,buttonP,searchP;operationT,search;operation;searchB,alert,insert,delete;private JTextField searchT;/ 搜索字样/centerBarprivateprivateJScrollPane scroll;JTablecontent;private MyTableModel model;private String list=new String;教师信息 ,教室信息 ,教室使用情况 ,教室具体使用情况private JLabel remind;public static void main(St

17、ring args)new ControlInterface();public ControlInterface()/登录界面 -login=new Login(this, 登录 ,true);/登陆界面回来之后/topBartopBar=new JPanel();new JLabel();userNameuserName.setText(Login.loginName);userName.setFont(new Font(隶书 ,1,25);/字体 ,1代表样式,字号userName.setLocation(this.getWidth()/2-userName.getWidth()/2,us

18、erName.getHeight()/3);topBar.add(userName,BorderLayout.CENTER);quit=new JButton(退出 );quit.setActionCommand(quit);quit.addActionListener(this); quit.setLocation(int) (this.getWidth()-quit.getWidth()*1.5),userName.getHeight()/3);topBar.add(quit,BorderLayout.EAST);this.add(topBar,BorderLayout.NORTH);/r

19、ightBarrightBar=new JPanel();rightBar.setLayout(new GridLayout(4,1);this.add(rightBar,BorderLayout.EAST);operationP=new JPanel();operationP.setLayout(new FlowLayout();operationT=new JLabel(选择表: );operation=new JComboBox(list);operation.addItemListener(new ItemListener()Overridepublic void itemStateC

20、hanged(ItemEvent arg0) searchT.setText(请输入 +operation.getSelectedItem().toString().substring(0,2)+ 编号 );model=new MyTableModel(operation.getSelectedItem().toString();content.setModel(model);) ;operationP.add(operationT);operationP.add(operation);buttonP=new JPanel();buttonP.setLayout(new GridLayout(

21、3,1);alert=new JButton(修改 );alert.addActionListener(this);alert.setActionCommand(alert);insert=new JButton(增加 );insert.addActionListener(this);insert.setActionCommand(insert);delete=new JButton(删除 );delete.addActionListener(this);delete.setActionCommand(delete);buttonP.add(alert); buttonP.add(insert

22、);buttonP.add(delete);operationP.add(buttonP);rightBar.add(operationP);search=new JLabel(关键字: );searchT=new JTextField(10);searchT.setText(请输入 +operation.getSelectedItem().toString().substring(0,2)+编号);searchB=new JButton(搜索 );searchB.addActionListener(this);searchB.setActionCommand(search);searchP=

23、new JPanel();searchP.setLayout(new FlowLayout();searchP.add(search);searchP.add(searchT);searchP.add(searchB);rightBar.add(searchP);remind=new JLabel();rightBar.add(remind);/centerBarmodel=new MyTableModel(operation.getSelectedItem().toString();content=new JTable(model);scroll=new JScrollPane(conten

24、t);this.add(scroll,BorderLayout.CENTER);this.setTitle(教室管理系统 );this.setResizable(false);this.setLocation(180,60);this.setSize(1000, 600);this.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);Overridepublic void actionPerformed(ActionEvent arg0) if(arg0.getActionCommand()=quit) Sy

25、stem.exit(0);if(arg0.getActionCommand()=search)search2UnionTable();return;if(String)operation.getSelectedItem()=教室具体使用情况)new RemindDialog(this, 提示 ,true,0);return;if(arg0.getActionCommand()=insert)new Insert(this,增加新数据 ,true,operation.getSelectedItem().toString();model=new MyTableModel(operation.get

26、SelectedItem().toString();content.setModel(model);return;if(content.getSelectedRow()=-1)new RemindDialog(this, 提示 ,true,1);return;if(arg0.getActionCommand()=alert)Vector v=(Vector)MyTableModel.rowData.get(content.getSelectedRow();new Update(this,修改 ,true,operation.getSelectedItem().toString(),v);mod

27、el=new MyTableModel(operation.getSelectedItem().toString();content.setModel(model);return;if(arg0.getActionCommand()=delete) Vector v=(Vector) MyTableModel.rowData.get(content.getSelectedRow();new Delete(this,删除 ,true,v,operation.getSelectedItem().toString();model=new MyTableModel(operation.getSelec

28、tedItem().toString();content.setModel(model);return;private void search2UnionTable()Vector v=MyTableModel.select(operation.getSelectedItem().toString();Vector rowData=new Vector();Iterator iterator=v.iterator();String rNum=searchT.getText().toString().trim();while(iterator.hasNext()Vector tem=(Vecto

29、r)iterator.next();if(String)tem.get(0).equals(rNum)rowData.add(tem);if(rowData.size()=0)remind.setText(-无该教室信息 -);return;elseremind.setText();MyTableModel my=new MyTableModel(rowData,MyTableModel.columnNames);content.setModel(my); 4.向主界面中加载数据package dev.chall.util;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQL

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1