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

📄 xuanobject.java

📁 本系统是基于CORBA实现的选课系统,具有一般选课系统的基本功能(查看学生基本信息,选课退课,查看成绩等),本系统主要是推荐给对刚进行CORBA学习的初学者来说有很大的重要性
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
import choose.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.io.*;
import java.util.*;

public class XuanObject extends _xuankeImplBase
{
	public XuanObject()
	{
		//default
	}
	
	public float login(String name,String passwd)
	{
		float aresult=0;
		try {
			// 取得数据库的连接
			Connection con = this.getConnection();
			// 创建一个声明,用来执行sql语句
			Statement sql = con.createStatement();
			// 执行查询数据库的sql语句
			String query="select * from login where id='"+name+"' and passwd='"+passwd+"'";
            // 执行查询,并返回一个结果集
			ResultSet result = sql.executeQuery(query);
        	
        	if(result.next())
        	{
        		aresult=1;
        	}  		
        	else
        	{
        		aresult=0;
        	}
			// 关闭声明和连接
			sql.close();
			con.close();

		} catch (java.lang.ClassNotFoundException e) {
			// 加载jdbc错误,所要用的驱动没找到
			e.printStackTrace();
			System.out.println("dfsdf"); 
			// 其他错误
		} catch (SQLException ex) {
			System.err.println("SQLException: " + ex.getMessage());
			// 显示数据库连接错误或者查询错误
		}
		return aresult;
	}
	
	public void updatepasswd(String id,String passwd)
	{
		try {
			// 取得数据库的连接
			Connection con = this.getConnection();
			// 创建一个声明,用来执行sql语句
			Statement sql = con.createStatement();
			// 执行查询数据库的sql语句
			String update="update login set passwd = '"+passwd+"' where id='"+id+"'";
            // 执行查询,并返回一个结果集
			sql.executeUpdate(update);
 	
			// 关闭声明和连接
			sql.close();
			con.close();

		} catch (java.lang.ClassNotFoundException e) {
			// 加载jdbc错误,所要用的驱动没找到
			e.printStackTrace();
			System.out.println("dfsdf"); 
			// 其他错误
		} catch (SQLException ex) {
			System.err.println("SQLException: " + ex.getMessage());
			// 显示数据库连接错误或者查询错误
		}
	}	
	
	private String name,sex,identity,born,jiguan,school,address,phone,email,beizhu;
	public String getbaseinf(String id)
	{				
		try {
			// 取得数据库的连接
			Connection con = this.getConnection();
			// 创建一个声明,用来执行sql语句
			Statement sql = con.createStatement();
			// 执行查询数据库的sql语句
			String query="select * from student_DT where stuid='"+id+"'";
            // 执行查询,并返回一个结果集
			ResultSet result = sql.executeQuery(query);
 			
 			while(result.next())
 			{
 				name = result.getString("name");
 				sex = result.getString("sex");				
 				jiguan = result.getString("jiguang");
 				born = result.getString("born");
 				identity = result.getString("identily");
 				school = result.getString("school");
 				address = result.getString("address");
 				phone = result.getString("phone");
 				email = result.getString("mail");
 				beizhu = result.getString("beizhu");
 			}
 			
			// 关闭声明和连接
			sql.close();
			con.close();

		} catch (java.lang.ClassNotFoundException e) {
			// 加载jdbc错误,所要用的驱动没找到
			e.printStackTrace();
			System.out.println("dfsdf"); 
			// 其他错误
		} catch (SQLException ex) {
			System.err.println("SQLException: " + ex.getMessage());
			// 显示数据库连接错误或者查询错误
		}
		System.out.println(name);
		String a = (name+","+sex+","+jiguan+","+born+","+identity+","+school+","+
		           address+","+phone+","+email+","+beizhu);
		System.out.println(a);
		try
		{
			a = new String(a.getBytes("ISO-8859-1"),"GBK");
			
		}catch(UnsupportedEncodingException e)
		{
			//default
		}
		return a;
		//return "abc";
	}
	private String courseid,coursename,xuefen,classtime,teachername,room,examtime,courseinf;
	private int row;
	public void getcourse(String term)
	{
		try {
			// 取得数据库的连接
			Connection con = this.getConnection();
			// 创建一个声明,用来执行sql语句
			Statement sql = con.createStatement();
			// 执行查询数据库的sql语句
			//if((term.substring(4,4)).equals("春"))
			//String query="select * from course_DT where courseid like '%"+term.substring(0,3)+"%'";
			String query="select * from course_DT";
            // 执行查询,并返回一个结果集
			ResultSet result = sql.executeQuery(query);
 			
 			int i=0;
 			courseid = "";
 			coursename= "";
 			xuefen = "";
 			classtime = "";
 			teachername= "";
 			room= "";
 			examtime= "";
 			courseinf= "";
 			
 			StringBuffer a = new StringBuffer();
 			while(result.next())
 			{
 				String courseid1 = result.getString("courseid");
 				String coursename1 = result.getString("coursename");
 				String xuefen1 = result.getString("xuefen");
 				String classtime1 = result.getString("classtime");
 				String teachername1 = result.getString("teachername");
 				String room1 = result.getString("room");
 				String examtime1 = result.getString("examtime");
 				String courseinf1 = result.getString("courseinf");
 				courseid += courseid1 + ",";
 				coursename += coursename1 +",";
 				xuefen += xuefen1 + ",";
 				classtime += classtime1 +",";
 				teachername += teachername1 +",";
 				room += room1 +",";
 				examtime += examtime1 +",";
 				courseinf += courseinf1 +",";
 				i++;
 			}
 			row = i;
 			System.out.println("===="+i);
			// 关闭声明和连接
			sql.close();
			con.close();

		} catch (java.lang.ClassNotFoundException e) {
			// 加载jdbc错误,所要用的驱动没找到
			e.printStackTrace();
			System.out.println("dfsdf"); 
			// 其他错误
		} catch (SQLException ex) {
			System.err.println("SQLException: " + ex.getMessage());
			// 显示数据库连接错误或者查询错误
		}
	}
	
	public String getcourseid()
	{
		return courseid;
	}
	
	public String getcoursename()
	{
		return coursename;
	}
	
	public String getxuefen()
	{
		return xuefen;
	}
	
	public String getclasstime()
	{
		return classtime;
	}
	
	public String getteachername()
	{
		return teachername;
	}
	
	public String getroom()
	{
		return room;
	}
	
	public String getexamtime()
	{
		return examtime;
	}
	
	public String getcourseinf()
	{
		return courseinf;
	}
	
	public int getline()
	{
		return row;
	}
	public void updatebaseinf(String id,String identity,String born,String jiguan,
	String school,String address,String phone,String mail,String beizhu)
	{
		try {
			// 取得数据库的连接
			Connection con = this.getConnection();
			// 创建一个声明,用来执行sql语句
			Statement sql = con.createStatement();
			// 执行查询数据库的sql语句
			String update1="update student_DT set identily='"+identity+"' where stuid='"+id+"'";
            String update2="update student_DT set born='"+born+"' where stuid='"+id+"'";
            String update3="update student_DT set jiguang='"+jiguan+"' where stuid='"+id+"'";
            String update4="update student_DT set school='"+school+"' where stuid='"+id+"'";
            String update5="update student_DT set address='"+address+"' where stuid='"+id+"'";
            String update6="update student_DT set phone='"+phone+"' where stuid='"+id+"'";
            String update7="update student_DT set mail='"+mail+"' where stuid='"+id+"'";
            String update8="update student_DT set beizhu='"+beizhu+"' where stuid='"+id+"'";
            // 执行查询,并返回一个结果集
			sql.executeUpdate(update1);	
			sql.executeUpdate(update2);
			sql.executeUpdate(update3);
			sql.executeUpdate(update4);
			sql.executeUpdate(update5);
			sql.executeUpdate(update6);
			sql.executeUpdate(update7);		
 			sql.executeUpdate(update8);
			// 关闭声明和连接
			sql.close();
			con.close();

		} catch (java.lang.ClassNotFoundException e) {
			// 加载jdbc错误,所要用的驱动没找到
			e.printStackTrace();
			System.out.println("dfsdf"); 
			// 其他错误
		} catch (SQLException ex) {
			System.err.println("SQLException: " + ex.getMessage());
			// 显示数据库连接错误或者查询错误
		}
	}
	
	public void insertcourse(String cid,String sid)
	{
		try {
			// 取得数据库的连接
			Connection con = this.getConnection();
			// 创建一个声明,用来执行sql语句
			Statement sql = con.createStatement();
			// 执行查询数据库的sql语句
			String update1="insert into choose_DT values('"+cid+"','"+sid+"')";

⌨️ 快捷键说明

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