addclass.java

来自「本远程教育系统是采用jsp技术配合SqlServer 2000数据库和Tomca」· Java 代码 · 共 49 行

JAVA
49
字号
/*
 *add one classroom into the table classes
 *contains two method:
 *setMode(ClassMode) to get the information of classroom from the classmode
 *add() to insert the information into the table
 */
package condb;
import java.sql.*;
import condb.ConDB;
import condb.ClassMode;
public class AddClass{
	private	String class_id;
	private String class_name;
	private String class_password;
	private String admin_id;
	private String xuanyan;
	public AddClass(){
		class_id = "";
		class_name = "";
		admin_id = "";
		class_password = "";
		xuanyan = "";
	}	
	public void setMode(ClassMode classmode){
		this.class_id = classmode.getClass_id();
		this.class_name = classmode.getClass_name();
		this.class_password = classmode.getClass_password();
		this.admin_id = classmode.getAdmin_id();
		this.xuanyan = classmode.getXuanyan();	
				
	}
	public int add(){
		int i=0;
		String sql = "insert into classes values('"+class_id+"','"
			+class_name+"','"+admin_id+"','"+class_password+"','"+xuanyan+"')";
		ConDB condb = new ConDB();
		Statement stmt = condb.getStmtread();
		try{
			i=stmt.executeUpdate(sql);
		}	
		catch(Exception e){
			System.err.println(e.getMessage());
			e.printStackTrace();
			i--;
		}
		condb.close();
		return i;
	}	
}

⌨️ 快捷键说明

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