学生信息管理系统完整源代码+mysql文件.docx
- 文档编号:28312833
- 上传时间:2023-07-10
- 格式:DOCX
- 页数:71
- 大小:31.70KB
学生信息管理系统完整源代码+mysql文件.docx
《学生信息管理系统完整源代码+mysql文件.docx》由会员分享,可在线阅读,更多相关《学生信息管理系统完整源代码+mysql文件.docx(71页珍藏版)》请在冰豆网上搜索。
学生信息管理系统完整源代码+mysql文件
数据库所用的数据自己导入MYSQL5.5,Navicat8就可以用了。
下面是具体的数据资料
/*
MySQLDataTransfer
SourceHost:
localhost
SourceDatabase:
sims
TargetHost:
localhost
TargetDatabase:
sims
Date:
2013-6-259:
24:
26
*/
SETFOREIGN_KEY_CHECKS=0;
------------------------------
--Tablestructureformanager
------------------------------
DROPTABLEIFEXISTS`manager`;
CREATETABLE`manager`(
`id`varchar(10)NOTNULL,
`name`varchar(30)NOTNULL,
`Mima`varchar(20)NOTNULL,
PRIMARYKEY(`id`)
)ENGINE=InnoDBDEFAULTCHARSET=utf8;
------------------------------
--Tablestructureforstudentinfo
------------------------------
DROPTABLEIFEXISTS`studentinfo`;
CREATETABLE`studentinfo`(
`Sname`varchar(30)NOTNULL,
`Ssex`varchar(10)NOT
NULL,
`Snumber`varchar(10)NOTNULL,
`Sprofession`varchar(30)NOTNULL,
`Sclass`
varchar(20)NOTNULL,
`Sdate`varchar(30)charactersetutf8collateutf8_unicode_ci
NOTNULL,
PRIMARYKEY(`Snumber`)
)ENGINE=InnoDBDEFAULTCHARSET=utf8COMMENT='InnoDB
free:
4096kB';
------------------------------
--Tablestructureforuserinfo
------------------------------
DROPTABLEIFEXISTS`userinfo`;
CREATETABLE`userinfo`(
`id`varchar(10)NOTNULL,
`name`varchar(30)NOTNULL,
`Mima`varchar(20)charactersetutf8collateutf8_unicode_ciNOTNULL,
PRIMARYKEY
(`id`)
)ENGINE=InnoDBDEFAULTCHARSET=utf8;
------------------------------
--Records
------------------------------
INSERTINTO`manager`VALUES('1','1','2');
INSERTINTO`manager`VALUES('2','恩恩','123456');
INSERTINTO`manager`VALUES('3','大大','123456');
INSERTINTO`manager`VALUES('4','啊啊','123456');
INSERTINTO`manager`VALUES('5','5','5');
INSERTINTO`manager`VALUES('6','孙霞','123456');
INSERTINTO`studentinfo`VALUES('张三','男','2010303755','数学','2','2010-02-
12');
INSERTINTO`studentinfo`VALUES('李四','男','2010303760','物理','1','1995.9.6');
INSERTINTO`studentinfo`VALUES('王二','女','2010303761','应数','2',
'1990.9.11');
INSERTINTO`studentinfo`VALUES('麻子','女','2010303762','信计','1',
'1999.9.10');
INSERTINTO`userinfo`VALUES('1','1','1');
INSERTINTO`userinfo`VALUES('13','13','1');
INSERTINTO`userinfo`VALUES('2','2','2');
INSERTINTO`userinfo`VALUES('3','3','3');
INSERTINTO`userinfo`VALUES('6','6','6');
INSERTINTO`userinfo`VALUES('7','7','6');
下面是相应的程序:
packageMS;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjava.awt.Color;
importjava.awt.Container;
importjava.awt.Dimension;
importjava.awt.GridLayout;
importjava.awt.Toolkit;
importjava.awt.event.FocusEvent;
importjava.awt.event.FocusListener;
importjava.sql.Connection;
importjava.sql.DriverManager;
importjava.sql.ResultSet;
importjava.sql.SQLException;
importjava.sql.Statement;
importjavax.swing.JButton;
importjavax.swing.JFrame;
importjavax.swing.JLabel;
importjavax.swing.JOptionPane;
importjavax.swing.JPanel;
importjavax.swing.JTextField;
importjavax.swing.SwingConstants;
publicclassAddimplementsActionListener{
JFramef1;
Containerct;
JPaneljp,jp1,jp2,jp3;
JButtonbtn1,btn2;
JLabellabel;
JTextFieldtf1,tf2,tf3,tf4,tf5,tf6;
Add(){
f1=newJFrame();
ct=f1.getContentPane();//初始化面板
jp=newJPanel();
jp1=newJPanel(newGridLayout(6,1));
jp2=newJPanel(newGridLayout(6,1));
jp3=newJPanel();
btn1=newJButton("确定");
btn2=newJButton("取消");
label=newJLabel("
label.setForeground(Color.gray);
tf1=newJTextField(20);
tf2=newJTextField(20);
tf3=newJTextField(20);
tf4=newJTextField(20);
tf5=newJTextField(20);
tf6=newJTextField(20);
tf6.setText("例:
2000-02-02");
//文本框加入提示语
tf6.addFocusListener(newFocusListener(){
publicvoidfocusGained(FocusEvente){
tf6.setText("");
}
publicvoidfocusLost(FocusEvente){}
});
jp.add(label);
ct.add(jp,"North");
jp1.add(newJLabel("姓名",SwingConstants.CENTER));
jp2.add(tf1);
jp1.add(newJLabel("性别",SwingConstants.CENTER));
jp2.add(tf2);
jp1.add(newJLabel("学号",SwingConstants.CENTER));
jp2.add(tf3);
jp1.add(newJLabel("专业",SwingConstants.CENTER));
jp2.add(tf4);
jp1.add(newJLabel("班级",SwingConstants.CENTER));
jp2.add(tf5);
jp1.add(newJLabel("入学时间",SwingConstants.CENTER));
jp2.add(tf6);
jp3.add(btn1);
jp3.add(btn2);
ct.add(jp1,"West");
ct.add(jp2,"East");
ct.add(jp3,"South");
Toolkitkit=Toolkit.getDefaultToolkit();
Dimensionscreen=kit.getScreenSize();
intx=screen.width;
inty=screen.height;
f1.setSize(350,330);
intxcenter=(x-350)/2;
intycenter=(y-330)/2;
f1.setLocation(xcenter,ycenter);
f1.setVisible(true);
//f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
btn1.addActionListener(this);
btn2.addActionListener(this);
}
publicvoidinsert(){
if(tf1.getText().equals("")||tf2.getText().equals("")||tf3.getText().equals("")||
tf4.getText().equals("")||tf5.getText().equals("")||tf6.getText().equals("")){
JOptionPane.showMessageDialog(f1,"请填写完整信息");
return;
}
try{
Class.forName("com.mysql.jdbc.Driver");
}catch(ClassNotFoundExceptione){
System.out.print("加载驱动程序失败");
}
StringconURL="jdbc:
mysql:
//localhost:
3306/sims";
try{
Connectioncon=DriverManager.getConnection(conURL,"root","123456");
Statementst=con.createStatement();
Strings="insertintostudentinfovalues('"+tf1.getText()+"','"+tf2.getText()+"','"+
tf3.getText()+"','"+tf4.getText()+"','"+tf5.getText()+"','"+tf6.getText()+"');";
Stringquery="select*fromstudentinfowhereSnumber='"+tf3.getText().trim()+"'";
ResultSetres=st.executeQuery(query);
if(res.next()){
JOptionPane.showMessageDialog(f1,"学号信息已经存在!
");
con.close();
tf3.setText("");
}elseif(tf6.getText().length()!
=10){
JOptionPane.showMessageDialog(f1,"入学时间格式有误!
");
con.close();
tf6.setText("");
}
intinsert=st.executeUpdate(s);
if(insert==1){
JOptionPane.showMessageDialog(f1,"录入信息成功!
");
tf1.setText("");
tf2.setText("");
tf3.setText("");
tf4.setText("");
tf5.setText("");
tf6.setText("");
}
}catch(SQLExceptione){
System.out.println("错误代码:
"+e.getErrorCode());
System.out.println("错误信息:
"+e.getMessage());
}
}
@SuppressWarnings("deprecation")
publicvoidactionPerformed(ActionEvente){
Stringcmd=e.getActionCommand();
if(cmd.equals("确定")){
insert();
}
elseif(cmd.equals("取消")){
f1.hide();
}
}
publicContainergetCt()
{
returnct;
}
publicvoidsetCt(Containerct)
{
this.ct=ct;
}
}
packageMS;
importjava.awt.BorderLayout;
importjava.awt.Color;
importjava.awt.Container;
importjava.awt.Dimension;
importjava.awt.Toolkit;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjava.sql.Connection;
importjava.sql.DriverManager;
importjava.sql.ResultSet;
importjava.sql.SQLException;
importjava.sql.Statement;
importjavax.swing.JButton;
importjavax.swing.JFrame;
importjavax.swing.JLabel;
importjavax.swing.JOptionPane;
importjavax.swing.JPanel;
importjavax.swing.JScrollPane;
importjavax.swing.JTable;
importjavax.swing.JTextField;
importjavax.swing.SwingConstants;
publicclassDeleteimplementsActionListener{
JFramef2;
Containerct;
JPaneljp1,jp2,jp3,jp4;
JLabellabel;
JTextFieldtext;
JTabletable;//接收数据库中返回的信息
JButtonbtn1,btn2,btn3;
ObjectcolumnName[]={"姓名","性别","学号","专业","班级","入学时间"};
Objectar[][]=newObject[80][6];
Delete(){
f2=newJFrame();
ct=f2.getContentPane();
jp1=newJPanel();
jp2=newJPanel();
jp3=newJPanel();
jp4=newJPanel();
label=newJLabel();
text=newJTextField();
btn1=newJButton("查询");
btn2=newJButton("删除");
btn3=newJButton("取消");
label=newJLabel("
",SwingConstants.CENTER);
label.setBackground(Color.blue);
table=newJTable(ar,columnName);
JScrollPanescroll=newJScrollPane(table);
text=newJTextField(20);
jp2.add(btn1);
jp2.add(btn2);
jp2.add(btn3);
jp1.add(label);
jp1.add(text);
ct.add(jp1,"North");
jp3.setLayout(newBorderLayout());
jp3.add(newJLabel("学生信息如下"));
jp3.add(scroll);
ct.add(jp2,"South");
ct.add(jp3,"Center");
Toolkitkit=Toolkit.getDefaultToolkit();
Dimensionscreen=kit.getScreenSize();
intx=screen.width;
inty=screen.height;
f2.setSize(450,400);
intxcenter=(x-450)/2;
intycenter=(y-400)/2;
f2.setLocation(xcenter,ycenter);
f2.setVisible(true);
//f2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
btn1.addActionListener(this);
btn2.addActionListener(this);
btn3.addActionListener(this);
}
inti=0;
publicvoidshow(Strings){
while(i>=0)
{
ar[i][0]="";
ar[i][1]="";
ar[i][2]="";
ar[i][3]="";
ar[i][4]="";
ar[i][5]="";
i--;
}
i=0;
try{
Class.forName("com.mysql.jdbc.Driver");
}catch(ClassNotFoundExceptione){
System.out.print("加载驱动程序失败");
}
StringconURL="jdbc:
mysql:
//localhost:
3306/sims";
try{
Connectioncon=DriverManager.getConnection(conURL,"root","123456");
Statementst=con.createStatement();
Stringsql="select*fromstudentinfowhereSname='"+s+"'";
ResultSetres=st.executeQuery(sql);
/*if(!
(res.next())){
JOptionPane.showMessageDialog(f,"所要查询的信息不存在");
}*/
while(res.next()){
StringsName=res.getString
(1);
StringsSex=res.getString
(2);
StringsNumber=res.getString(3);
StringsProfession=res.getString(4);
StringsClass=
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 学生 信息管理 系统 完整 源代码 mysql 文件
![提示](https://static.bdocx.com/images/bang_tan.gif)