📄 teacher.java
字号:
package database;
import java.sql.*;
public class teacher {
String id;
String name;
String password;
String title;
public void setPassword(String s) {
password = s;
}
public String getPassword() {
return password;
}
public void setName(String s) {
name = s;
}
public String getName() {
return name;
}
public void setTitle(String s) {
title = s;
}
public String getTitle() {
return title;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public ResultSet getCourse() {
String sql = "select course.name " + "from classes,course "
+ "where classes.tea_id='" + id + "' "
+ "and course.id=classes.cour_id";
sqlBean sqlbean = new sqlBean();
ResultSet rs = sqlbean.executeQuery(sql);
return rs;
}
// 检查该教师是否已经注册
public boolean hasLogin(String id) {
boolean f = true;
String sql = "select id from teacher where id ='" + id + "'";
sqlBean db = new sqlBean();
try {
ResultSet rs = db.executeQuery(sql);
if (rs.next()) {
f = false;
} else {
f = true;
}
} catch (Exception e) {
e.getMessage();
}
return f;
}
public void addTeacher() {
String sql = "insert into teacher(id,name,title,password) "
+ "values('" + id + "','" + name + "','" + title + "','"
+ password + "') ";
sqlBean db = new sqlBean();
db.executeUpdate(sql);
}
public ResultSet getAll() {
String sql = "select * from teacher";
sqlBean db = new sqlBean();
ResultSet rs = db.executeQuery(sql);
return rs;
}
public void update() {
String sql = "update teacher set name='" + name + "', " + "title='"
+ title + "' ,password='" + password + "' " + "where id='" + id
+ "' ";
sqlBean db = new sqlBean();
db.executeUpdate(sql);
}
public int delete(String id) {
int num = 0;
String sql = "delete from teacher where id ='" + id + "' ";
sqlBean db = new sqlBean();
num = db.executeUpdate(sql);
return num;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -