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

📄 findexactresult.java

📁 远程电子考试系统
💻 JAVA
字号:
package fangsoft.testcenter.driver;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import dbconnect.DbConnect;
import fangsoft.testcenter.model.Customer;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class FindExactResult {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws SQLException 
	 */
	public static void main(String[] args) throws IOException, SQLException {
		// TODO 自动生成方法存根
		DbConnect dbcon=new DbConnect();
		dbcon.connect();
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		String s = null;
		System.out.println("是否查询你的详细考试记录?");
		System.out.println("1.是:y\n2.否:n");
		s = reader.readLine();
		if ("y".equalsIgnoreCase(s)) {
			Statement stmt;
			stmt = (dbcon.getConnction()).createStatement();
			BufferedReader br = new BufferedReader(new InputStreamReader(
					System.in));
			int count = 0;
			String userId = null, password;
			int MAX_RETRIES = 3;
			//String dt = null;
			for (count = 0; count < MAX_RETRIES; count++) {
				System.out.println("输入用户名称:");
				userId = br.readLine();
				System.out.println("输入用户密码:");
				password = br.readLine();

				if (Customer.login(userId, password, dbcon.getConnction())) {
					break;
				}
				System.out.println("用户名或密码错误不能登录,重新登录." + "登录" + MAX_RETRIES
						+ "次不成功,系统将退出." + "这是" + (count + 1) + "次");
			}
			if (count == MAX_RETRIES) {
				System.out.println("登录" + MAX_RETRIES + "次不成功,系统退出");
				System.exit(0);
			}
			//dt = getInput("请输入考试时间:");
			ResultSet check = stmt
					.executeQuery("select * from EXACTRESULT where customer_name = '" + userId
							+ "'");// 执行查询
			System.out.println("时间\t题号\t答案\t正确答案\t判断");
			while (check.next()) {// 判断是否存在查询结构
				System.out.print(check.getString("date_time"));
				System.out.print("\t"+check.getString("question_no"));
				System.out.print("\t" + check.getString("answer"));
				System.out.print("\t" + check.getString("correct_answer"));
				System.out.println("\t" + check.getString("judge"));
				
			}
			check.close();
		} else {
			System.out.println("系统退出");
			System.exit(0);
		}
	}
	public static String getInput(String msg) {
		String result = null;
		try {
			// 创建用户输入流
			BufferedReader in = new BufferedReader(new InputStreamReader(
					System.in));
			System.out.print(msg);
			result = in.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return result;
	}

}

⌨️ 快捷键说明

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