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

📄 scoretable.java

📁 这是一个可以在手机客户端运行的选课系统 这个是客户端
💻 JAVA
字号:
package jdbc;
import java.sql.*;

public class ScoreTable
{ 
	private String command=null;
	private Statement statement=null;
	
	public ScoreTable(Statement statement)
	{
		this.statement=statement;	
	}
	
	public int insert(String studentID,String courseName,int term,int compulsory,String score) throws SQLException
	{
		command="INSERT INTO ScoreTable VALUES ('"+studentID+"','"+courseName+"','"+term+"',"+compulsory+",'"+score+"')";
		return statement.executeUpdate(command);
	}
	
	public int delete(String studentID) throws SQLException
	{
		if (studentID==null)
			command="DELETE FROM ScoreTable";
		else
			command="DELETE FROM ScoreTable WHERE studnetID='"+studentID+"'";		
		return statement.executeUpdate(command);
	}
	
	public int update(String studentID,String courseName,int compulsory,int term,String score) throws SQLException
	{
		command="UPDATE ScoreTable SET courseName='"+courseName+"',compulsory="+compulsory+",term="+term+",score='"+score+"' WHERE studentID='"+studentID+"'";
		return statement.executeUpdate(command);	
	}
	
	public ResultSet select(String studentID,int term) throws SQLException
	{
		if(term==0)
			command="select * from scoretable where studentid='"+studentID+"'";
		else	
			command="select * from scoretable where studentid='"+studentID+"' and term="+term;
		return statement.executeQuery(command);
	}
	
	public int selectNum(String studentID,int term) throws SQLException
	{
		if(term==0)
			command="SELECT COUNT(*) FROM ScoreTable where studentID='"+studentID+"'";
		else
			command="SELECT COUNT(*) FROM ScoreTable where studentID='"+studentID+"' and term="+term;
		ResultSet rs=statement.executeQuery(command);
		rs.next();
		return rs.getInt(1);
	}
}

⌨️ 快捷键说明

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