package yangxiaoxin.Student;
import java.awt.FlowLayout;
import java.sql.*;
import javax.swing.*;
public class Query extends JFrame{
Connection conn=null;
Statement cmd=null;
public void connect(){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("jdbc:odbc:myodbc","","");
cmd=conn.createStatement();
}
catch(Exception e1){
System.out.println(e1);
}
}
public Query(){//缺省构造函数
};
//下面为一系列构造函数的重载 分别用来实现不同的功能 形参只是为了区分各个构造函数 无实际意义
public Query(int m){//用来查询学生信息的窗口
try{
connect();
JPanel jp=(JPanel)this.getContentPane();
String []line={"学号","班级号","姓名","性别","院系号"};
String sql="select count(*) from Student_20071734";
ResultSet rs=cmd.executeQuery(sql);
int c=0;
while(rs.next())
c=rs.getInt(1);
String [][]col=new String[c][5];
sql="select * from Student_20071734";
rs=cmd.executeQuery(sql);
for(int i=0;i<c;i++){
rs.next();
for(int j=1;j<6;j++)
col[i][j-1]=rs.getString(j);
}
System.out.print(col[0][0]);
JTable tbl=new JTable(col,line);
jp.add(new JScrollPane().add(tbl));
conn.close();
}
catch(Exception e1){
System.out.println(e1);
}
}
public Query(int m,double n){//用来查询课程信息的窗口
try{
connect();
JPanel jp=(JPanel)this.getContentPane();
String []line={"课程号","课程名","教师名","学分"};
String sql="select count(*) from Course_20071734";
ResultSet rs=cmd.executeQuery(sql);
int c=0;
while(rs.next())
c=rs.getInt(1);
String [][]col=new String[c][5];
sql="select * from Shopping";
rs=cmd.executeQuery(sql);
for(int i=0;i<c;i++){
rs.next();
for(int j=1;j<5;j++)
col[i][j-1]=rs.getString(j);
}
JTable tbl=new JTable(col,line);
jp.add(new JScrollPane().add(tbl));
conn.close();
}
catch(Exception e1){
System.out.println(e1);
}
}
public Query(double n,int m){//用来查询成绩信息的窗口
try{
connect();
JPanel jp=(JPanel)this.getContentPane();
String []line={"学号","课程号","成绩"};
String sql="select count(*) from Grade_20071734";
ResultSet rs=cmd.executeQuery(sql);
int c=0;
while(rs.next())
c=rs.getInt(1);
String [][]col=new String[c][4];
sql="select * from Grade_20071734";
rs=cmd.executeQuery(sql);
for(int i=0;i<c;i++){
rs.next();
for(int j=1;j<4;j++)
col[i][j-1]=rs.getString(j);
}
JTable tbl=new JTable(col,line);
jp.add(new JScrollPane().add(tbl));
conn.close();
}
catch(Exception e1){
System.out.println(e1);
}
}
public Query(double n){//用来查询班级信息的窗口
try{
connect();
JPanel jp=(JPanel)this.getContentPane();
String []line={"班级号","年级号","班主任号"};
String sql="select count(*) from Class_20071734";
ResultSet rs=cmd.executeQuery(sql);
int c=0;
while(rs.next())
c=rs.getInt(1);
String [][]col=new String[c][4];
sql="select * from Class_20071734";
rs=cmd.executeQuery(sql);
for(int i=0;i<c;i++){
rs.next();
for(int j=1;j<4;j++)
col[i][j-1]=rs.getString(j);
}
JTable tbl=new JTable(col,line);
jp.add(new JScrollPane().add(tbl));
conn.close();
}
catch(Exception e1){
System.out.println(e1);
}
}
public Query(String n,double m){//用来查询教师信息的窗口
try{
connect();
JPanel jp=(JPanel)this.getContentPane();
String []line={"教师号","教师名","教师职称","院系号"};
String sql="select count(*) from Teacher_20071734";
ResultSet rs=cmd.executeQuery(sql);
int c=0;
while(rs.next())
c=rs.getInt(1);
String [][]col=new String[c][4];
sql="select * from Teacher_20071734";
rs=cmd.executeQuery(sql);
for(int i=0;i<c;i++){
rs.next();
for(int j=1;j<5;j++)
col[i][j-1]=rs.getString(j);
}
JTable tbl=new JTable(col,line);
jp.add(new JScrollPane().add(tbl));
conn.close();
}
catch(Exception e1){
System.out.println(e1);
}
}
public Query(double n,double m){//用来查询院系信息的窗口
try{
connect();
JPanel jp=(JPanel)this.getContentPane();
String []line={"院系号","院系名"};
String sql="select count(*) from dept_20071734";
ResultSet rs=cmd.executeQuery(sql);
int c=0;
while(rs.next())
c=rs.getInt(1);
String [][]col=new String[c][3];
sql="select * from dept_20071734";
rs=cmd.executeQuery(sql);
for(int i=0;i<c;i++){
rs.next();
for(int j=1;j<3;j++)
col[i][j-1]=rs.getString(j);
}
JTable tbl=new JTable(col,line);
jp.add(new JScrollPane().add(tbl));
conn.close();
}
catch(Exception e1){
System.out.println(e1);
}
}
public Query(String n,String m){//用来查询授课信息的窗口
try{
connect();
JPanel jp=(JPanel)this.getContentPane();
String []line={"教师号","课程号","上课时间","上课地点"};
String sql="select count(*) from Teachering_20071734";
ResultSet rs=cmd.executeQuery(sql);
int c=0;
while(rs.next())
c=rs.getInt(1);
String [][]col=new String[c][5];
sql="select * from Teachering_20071734";
rs=cmd.executeQuery(sql);
for(int i=0;i<c;i++){
rs.next();
for(int j=1;j<5;j++)
col[i][j-1]=rs.getString(j);
}
JTable tbl=new JTable(col,line);
jp.add(new JScrollPane().add(tbl));
conn.close();
}
catch(Exception e1){
System.out.println(e1);
}
}
public void StudentDelete(){
try{
this.connect();
String s=JOptionPane.showInputDialog("请输入要删除学号").toString().trim();
String sql="delete from Student_20071734 where sno='"+s+"'";
System.out.println(sql);
cmd.executeUpdate(sql);
conn.close();
}
catch(Exception e1){
System.out.println(e1);
}
}
public void CourseDelete(){
try{
this.connect();
String s=JOptionPane.showInputDialog("请输入要删除课程号");
String sql="delete from Course_20071734 where cno="+s;
System.out.println(sql);
cmd.executeUpdate(sql);
conn.close();
}
catch(Exception e1){
System.out.println(e1);
}
}
public void GradeDelete(){
try{
this.connect();
String s=JOptionPane.showInputDialog("请输入要删除学号");
String t=JOptionPane.showInputDialog("请输入要删除学号");
String sql="delete from Grade_20071734 where sno="+t+"cno="+s;
System.out.println(sql);
cmd.executeUpdate(sql);
conn.close();
}
catch(Exception e1){
System.out.println(e1);
}
}
public void ClassDelete(){
try{
this.connect();
String s=JOptionPane.showInputDialog("请输入要删除班级号");
String sql="delete from Class_20071734 where classno="+s;
System.out.println(sql);
cmd.executeUpdate(sql);
conn.close();
}
catch(Exception e1){
System.out.println(e1);
}
}
public void TeacherDelete(){
try{
this.connect();
String s=JOptionPane.showInputDialog("请输入要删除教师号");
String sql="delete from Teacher_20071734 where teacherno="+s;
System.out.println(sql);
cmd.executeUpdate(sql);
conn.close();
}
catch(Exception e1){
System.out.println(e1);
}
}
public void deptDelete(){
try{
this.connect();
String s=JOptionPane.showInputDialog("请输入要删除院系号");
String sql="delete from d
等天晴i
- 粉丝: 5924
- 资源: 10万+
最新资源
- FeiQ.rar 局域网内通信服务软件
- 172.16.100.195
- 光储并网simulink仿真模型,直流微电网 光伏系统采用扰动观察法是实现mppt控制,储能可由单独蓄电池构成,也可由蓄电池和超级电容构成的混合储能系统,并采用lpf进行功率分配 并网采用pq控制
- python编写微信读取smart200plc的数据发送给微信联系人
- 光储并网VSG系统Matlab simulink仿真模型,附参考文献 系统前级直流部分包括光伏阵列、变器、储能系统和双向dcdc变器,后级交流子系统包括逆变器LC滤波器,交流负载 光储并网VSG系
- file_241223_024438_84523.pdf
- 质子交膜燃料电池PEMFC Matlab simulink滑模控制模型,过氧比控制,温度控制,阴,阳极气压控制
- IMG20241223015444.jpg
- 模块化多电平变器(MMC),本模型为三相MMC整流器 控制策略:双闭环控制、桥臂电压均衡控制、模块电压均衡控制、环流抑制控制策略、载波移相调制,可供参考学习使用,默认发2020b版本及以上
- Delphi 12 控件之FlashAV FFMPEG VCL Player For Delphi v7.0 for D10-D11 Full Source.7z
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
前往页