java学生信息录入和查询(连接mysql数据库).doc





《java学生信息录入和查询(连接mysql数据库).doc》由会员分享,可在线阅读,更多相关《java学生信息录入和查询(连接mysql数据库).doc(25页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、Four short words sum up what has lifted most successful individuals above the crowd: a little bit more.-author-datejava学生信息录入和查询(连接mysql数据库)成绩录入1. 成绩录入package studentManage;import java.awt.GridLayout; import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;i
2、mport java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.*;public class StudentManageSystem extends JFrameJTextField jtfdID = new JTextField(8);JTextField jtfdName = new JTextField(128);JTextField jtfdSex = new JTextField(128);J
3、TextField jtfdAge = new JTextField(8);public StudentManageSystem()JButton jbtnEnter= new JButton(录入);JButton jbtnClear= new JButton(清零);JLabel jlblID = new JLabel(学号);JLabel jlblName = new JLabel(姓名);JLabel jlblSex = new JLabel(性别);JLabel jlblAge = new JLabel(年龄);setLayout(new GridLayout(5,2,5,5);ad
4、d(jlblID);add(jtfdID);add(jlblName);add(jtfdName);add(jlblSex);add(jtfdSex);add(jlblAge);add(jtfdAge);add(jbtnEnter);add(jbtnClear);jbtnEnter.addActionListener(new EnterListener();jbtnClear.addActionListener(new ClearListener();class EnterListener implements ActionListenerpublic void actionPerformed
5、(ActionEvent e)Boolean rs = null;tryClass.forName(com.mysql.jdbc.Driver);Connection conn = DriverManager.getConnection(jdbc:mysql:/127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf8,root1,root);Statement stmt = conn.createStatement();String sql = insert into student values(+jtfdID.getText()+
6、,+jtfdName.getText()+,+jtfdSex.getText()+,+jtfdAge.getText()+); stmt.execute(sql); jtfdID.setText( );jtfdName.setText( );jtfdSex.setText( );jtfdAge.setText( );catch (ClassNotFoundException e2) System.out.println(Sorry,cant find the Driver!);e2.printStackTrace(); catch (SQLException e3) e3.printStack
7、Trace(); catch (Exception e4) e4.printStackTrace();class ClearListener implements ActionListenerpublic void actionPerformed(ActionEvent e)jtfdID.setText();jtfdName.setText();jtfdSex.setText();jtfdAge.setText();public static void main (String args)StudentManageSystem s = new StudentManageSystem();s.s
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- java 学生 信息 录入 查询 连接 mysql 数据库

限制150内