📄 209c750dfb4f001d1594abca140770d0
字号:
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
class courseText1 extends JFrame implements ActionListener
{ TextArea text1;
Label label1,label2,label3;
Button buttonSure;
courseText1(String s)
{ super(s);
setLayout(new FlowLayout());
text1=new TextArea(10,33);
buttonSure=new Button("确定");
label1 =new Label("课程编号");
add(label1);
label2 =new Label("课程名");
add(label2);
label3 =new Label("教师");
add(label3);
add(text1);
add(buttonSure);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
text1.setEditable(false);
buttonSure.addActionListener(this);
setBounds(120,120,300,300);
setVisible(true);
validate();
}
public void actionPerformed(ActionEvent e)
{ Connection con=null;
Statement sql=null;
ResultSet rs=null;
try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch ( ClassNotFoundException ee )
{ System.out.print( " " + ee);
}
try
{ con=DriverManager.getConnection("jdbc:odbc:sun","","");
sql=con.createStatement();
rs=sql.executeQuery("SELECT * FROM 课程信息表");
while(rs.next())
{ String courseno =rs.getString(1);
String course =rs.getString(2);
String teacher =rs.getString(3);
text1.append("课程编号"+courseno+" ");
text1.append("课程名"+course+" ");
text1.append("教师"+teacher+"\n");
}
con.close();
}
catch( SQLException cc)
{
System.out.println("mmmmmmmm");
}
}
}
/*public class courseText
{ public static void main(String args[])
{ courseText1 win=new courseText1("成绩表");
}
} */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -