实验四 访问数据库应用实例
一. 实验目的:
能够熟练运用某种高级语言进行数据库编程。
二. 实验要求:
根据上次实验所使用的组件,编写一个访问数据库的程序,要求该程序具备查询、插入、删除、修改四个基本功能。
三. 实验过程:
特别声明一下:
Java在图形界面设计上,和其他高级语言不太一样。Java都是通过各种类的继承重写和方法的实现达到的。
主窗口完整代码:
import java.awt.*;
import java.io.*;
import java.awt.event.*;
public class MainWin{
public static void main(String args[]){ } class mybutton extends Frame implements ActionListener{ Label l;Button button1,button2,button3,button4,button5; mybutton(String s){ super(s); l = new Label ("请按提示选择功能"); setLayout(new FlowLayout()); button1 = new Button("查询");add(button1); button2 = new Button("添加");add(button2); button3 = new Button("修改");add(button3); button4 = new Button("删除");add(button4); button5 = new Button("退出");add(button5); button1.addActionListener(this); button2.addActionListener(this); button3.addActionListener(this); button4.addActionListener(this); button5.addActionListener(this); setVisible(true);validate();} public void actionPerformed(ActionEvent e){ mybutton bn = new mybutton("欢迎使用学生信息查询系统"); bn.setSize(250,250);}