⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 threehaoliulan.java

📁 高校大学生住宿安排和管理系统,住宿安排和住宿管理是两个核心和好用的强大功能。 本系统以学年度为存储单位,以学期为管理单位,只需录入一个学期的住宿信息,后续学期的住宿信息可以复制产生。
💻 JAVA
字号:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
import java.sql.*;
public class threehaoliulan extends JFrame implements ActionListener
{
	public static void main(String[] args)
	{
		threehaoliulan frame=new threehaoliulan();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		frame.show();
	}
	JButton bu1;
	JTextArea ta1;
	public threehaoliulan()
	{
		super("3号楼住宿花名册");
		setSize(550,550);
		Container c=getContentPane();
		JPanel textPanel=new JPanel();
		JPanel p=new JPanel();
		ta1=new JTextArea("",25,35);
		//ta1.setSize(500,400);
		JScrollPane scrollPane=new JScrollPane(ta1);
		//c.setLayout(null);
		bu1=new JButton("读取ODBC数据库");
		bu1.setSize(100,20);
		//bu1.setLocation(450,20);
		bu1.addActionListener(this);
		c.add(bu1);
		
		
		//ta1.setSize(450,380);
		//ta1.setLocation(20,50);
		//c.add(ta1);
		
		textPanel.add(scrollPane);
		//textPanel.setLocation(10,30);
		JComboBox jobsBox=new JComboBox();
		p.add(jobsBox);
		jobsBox.addItem("afsdfsdf");
		jobsBox.addItem("bfsdfsdfsd");
		c.add(p,BorderLayout.WEST);
		
		c.add(textPanel,BorderLayout.AFTER_LAST_LINE);
		//JScrollPane scrollPane=new JScrollPane(ta1);
		//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		//setVisible(true);
	}
	public void actionPerformed(ActionEvent e)
	{
		String str1="";
		try
		{
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		}
		catch(ClassNotFoundException e1)
		{
			System.out.println("Driver not found!");
		}
			try{
			Connection con1=DriverManager.getConnection("jdbc:odbc:student");
			Statement st1=con1.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
			ResultSet rs1=st1.executeQuery("select * from 2号楼住宿花名册");
			while(rs1.next())
			{
				str1=str1+rs1.getString(1)+"    "+rs1.getString(2)+"    "+rs1.getString(3)+"    "+
				rs1.getString(5)+"    "+rs1.getString(6)+"    "+rs1.getString(7)+"\n";
			}
			st1.close();
			con1.close();
			ta1.setText(str1);
			JOptionPane.showMessageDialog(null,"数据库加载成功!");
		}
		catch(SQLException e2)
		{
			System.out.println("table not found!");
		}
	}
}				

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -