studenttable.java
来自「这是一个可以在手机客户端运行的选课系统 这个是客户端」· Java 代码 · 共 60 行
JAVA
60 行
/*
* 创建日期 2005-3-11
*
* 更改所生成文件模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
package jdbc;
import java.sql.*;
/**
* @author Owner
*
* 更改所生成类型注释的模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
public class StudentTable
{
private String command=null;
private Statement statement=null;
public StudentTable(Statement statement)
{
this.statement=statement;
}
public int insert(String studentID,String password) throws SQLException
{
command="INSERT INTO StudentTable VALUES ('"+studentID+"','"+password+"',0";
return statement.executeUpdate(command);
}
public int delete(String studentID) throws SQLException
{
command="DELETE FROM StudentTable WHERE StudentID='"+studentID+"'";
return statement.executeUpdate(command);
}
public int updatePassword(String studentID,String password) throws SQLException
{
command="UPDATE StudentTable SET Password='"+password+"'"+" WHERE StudentID='"+studentID+"'";
return statement.executeUpdate(command);
}
public boolean updateCourseChosen(String studentID,int courseChosen) throws SQLException
{
command="UPDATE StudentTable SET CourseChosen="+courseChosen+""+" WHERE StudentID='"+studentID+"'";
statement.executeUpdate(command);
return true;
}
public ResultSet select(String studentID) throws SQLException
{
if(studentID==null)
command="SELECT * FROM STUDENTTABLE";
else
command="SELECT * FROM STUDENTTABLE WHERE StudentID='"+studentID+"'";
return statement.executeQuery(command);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?