欢迎来到天天文库
浏览记录
ID:51963379
大小:61.00 KB
页数:19页
时间:2020-03-20
《学生管理系统(图形界面)-Java.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、学生管理系统(图形界面)——Java源代码:packageexp10;importjavax.swing.JFrame;publicclassMainClass{/***@paramargs*/publicstaticvoidmain(String[]args){//TODOAuto-generatedmethodstubJFramemyFrame=newJFrame("学生成绩管理系统");myFrame.setLocation(300,100);//myFrame.setContentPane(newLoginPane(myFrame));myFrame.pa
2、ck();myFrame.setVisible(true);}}packageexp10;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;publicclassDataBase{Connectionconn=null;publicConnectiongetConn(){returnthis.conn;}publicvoidsetConn(Connec
3、tionconn){this.conn=conn;}publicbooleangetConnection(){Stringurl="jdbc:mysql://localhost:3306/ScoreManagement?user=root&password=123";try{Class.forName("org.gjt.mm.mysql.Driver");conn=DriverManager.getConnection(url);returntrue;}catch(SQLExceptione){System.out.println(e.getMessage());
4、returnfalse;}catch(ClassNotFoundExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();returnfalse;}}publicResultSetexecuteQuery(Stringsql){ResultSetrs=null;Statementstmt=null;if(conn==null){this.getConnection();}try{stmt=conn.createStatement();rs=stmt.executeQuery(sql);returnr
5、s;}catch(SQLExceptione){returnnull;}}publicintexecuteUpdate(Stringsql){Statementstmt=null;intlinecount=0;if(conn==null){this.getConnection();}try{stmt=conn.createStatement();linecount=stmt.executeUpdate(sql);}catch(SQLExceptione){}returnlinecount;}}packageexp10;importjava.awt.event.Ac
6、tionEvent;importjava.awt.event.ActionListener;importjava.sql.ResultSet;importjava.sql.SQLException;importjavax.swing.Box;importjavax.swing.ButtonGroup;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JPanel;importjavax.swing.JPasswordField;
7、importjavax.swing.JRadioButton;importjavax.swing.JTextField;publicclassLoginPaneextendsJPanelimplementsActionListener{/****/privatestaticfinallongserialVersionUID=1L;JFramemyFrame;JLabellab_username=newJLabel("用户名");JTextFieldjt_username=newJTextField(20);JLabellab_password=newJLabel(
8、"密码")
此文档下载收益归作者所有