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

📄 bean_pigai.java

📁 在线考试系统
💻 JAVA
字号:
package com.gton.bean;
import java.util.ArrayList;
import java.io.*;
import java.sql.*;

import com.gton.bean.*;
import com.gton.bean.util.*;

public class bean_pigai {
	int number;
	String title;
	DB_Conn db_conn=new DB_Conn();
	ResultSet  i=null;
	private  Connection p_conn=null;
	String p_path;

	public String getP_path() {
		return p_path;
	}

	public void setP_path(String p_path) {
		this.p_path = p_path;
	}

	public int getNumber() {
		return number;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public void setNumber(int number) {
		this.number = number;
	}
//////////////////////////////////////////////////////
////	////////获取考生试题
	public ArrayList getTestList(String Number)
	{ 
		ArrayList list = new ArrayList();
	    db_conn.ConnectDB();
	 try 
		{
			String sql ="select * from 试卷 where 题型='" + 4+ "'and 准考证号='"+Number+"'order by NEWID()";
			i=db_conn.sm.executeQuery(sql);
			while(i.next())
			{
			   bean_pigai tb=new bean_pigai();	 
			   tb.setNumber(i.getInt("题号"));
			   tb.setTitle(i.getString("题目"));
			    list.add(tb);
			  }
		}
	   catch(Exception e)
	     {
			e.printStackTrace();
	   	    System.out.print("数据库连接失败!");
		 }
	   return list;
	}
	///////////////////////////////////////
	///////////学生主观题分数录入
	public boolean update_mark(String studentid,int pro_num,float mark)
	{
		   db_conn.ConnectDB();
			 try 
				{
				
				  String sql="update 试卷 set 得分="+mark+" where 准考证号='"+studentid+"' and 题号="+pro_num+"and 题型='4'";
				  if(db_conn.sm.executeUpdate(sql)==0)
					  return false;
				
				}
			 catch(Exception e)
		     {
				e.printStackTrace();
		   	    System.out.print("数据库连接失败!");
			 }
		return true;
	}
	
	///////////////////////////////
	///////客观题存储过程
	public void p_keguan()
	{ 	
	    String procedure_name="pro_GaiJuan";
		String call_procedure_string="{call "+procedure_name+"}";
	
		try
		{
	
		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        p_conn=DriverManager.getConnection("jdbc:odbc:Exam"); 
		
        CallableStatement callable_statment=p_conn.prepareCall(call_procedure_string);
	    callable_statment.executeUpdate();
	   // conn.commit();
	    callable_statment.close();
	      }
	   catch(Exception e)
     {
		e.printStackTrace();
		System.out.print("数据库连接失败!");
	 }
	   finally
	   {
		 try
		 { 
			 p_conn.close();
		 }
		 catch(Exception e)
	     {
			e.printStackTrace();
			System.out.print("数据库连接失败!");
		 }
	   }
   }
	////////
//////////总分存储过程
	public void p_zongfen(String stuid)
	{ 	
	    String procedure_name="ZongFen";
		String call_procedure_string="{call "+procedure_name+"(?)}";
	
		try
		{
	
		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        p_conn=DriverManager.getConnection("jdbc:odbc:Exam"); 
        CallableStatement callable_statment=p_conn.prepareCall(call_procedure_string);
        callable_statment.setString(1, stuid);
	    callable_statment.executeUpdate();
	   // conn.commit();
	    callable_statment.close();
	      }
	   catch(Exception e)
     {
		e.printStackTrace();
		System.out.print("数据库连接失败!");
	 }
	   finally
	   {
		 try
		 { 
			 p_conn.close();
		 }
		 catch(Exception e)
	     {
			e.printStackTrace();
			System.out.print("数据库连接失败!");
		 }
	   }
   }
	
	public bean_pigai path(String stuid)
	{
		db_conn.ConnectDB();
		bean_pigai tb=new bean_pigai();	 
		 try 
			{
				String sql ="select distinct 学生答案 from 试卷 where 题型='" + 4+"' and 准考证号='"+stuid+"'";
				i=db_conn.sm.executeQuery(sql);
				
			if(i.next())	
		    tb.setP_path(i.getString("学生答案"));				  				 
			}
		   catch(Exception e)
		     {
				e.printStackTrace();
		   	    System.out.print("数据库连接失败!");
			 }
		   return tb;
	}
	
	
	//public static void main(String[] args) 
	//{
		
	//	bean_pigai d=new bean_pigai();
		//d.update_mark("2003010120",2,(float) 2.5);
		//d.p_keguan();
		//d.p_zongfen("2003010101");
		//d=d.path("2003010120");
		//System.out.print(d.getP_path());
		
 // }
}
	

⌨️ 快捷键说明

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