import java.sql.*;
public class InsertTestData {
public static void main(String[] args){
	String sql = "";
	String classid[] = new String[3];
	classid[0] = "20"; classid[1] = "30"; classid[2] = "40";
	try{
		new oracle.jdbc.driver.OracleDriver();
		Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ora9","scott","tiger");
		sql = "insert into test_question_lib values(test_seq_question.nextval,?,?,?,?,?,?,?,?)";

		PreparedStatement stmt=conn.prepareStatement( sql );
		for(int i=0; i<500; i++) {
		// 设置题型
		stmt.setInt(1,(int) (Math.floor(2*Math.random()) + 1));  // 设置班级代号
		stmt.setString(2,classid[(int)(Math.floor(3*Math.random()))]);    
		stmt.setString(3,"Test question  " + i*i);	
		stmt.setString(4,"selection 1");	
		stmt.setString(5,"selection 2");	
		stmt.setString(6,"selection 3");	
		stmt.setString(7,"selection 4");	
		stmt.setString(8,"A")；
		stmt.executeUpdate();
	}
	}catch(SQLException e){
		System.err.println(e);
	}
	stmt.close();
	conn.close();
	}
}
