updatechengjiaction.java~2~
来自「java(Swing) access做的成绩管理系统」· JAVA~2~ 代码 · 共 54 行
JAVA~2~
54 行
package edu.xscj.action;
import java.sql.Connection;
import edu.xscj.conn.ConnectDataBase;
import java.sql.PreparedStatement;
import edu.xscj.bean.Chengji;
public class UpdateChengjiAction {
Connection conn = null;
public UpdateChengjiAction() {
if (conn == null) {
conn = ConnectDataBase.getConn();
}
}
public void setConn() {
if (conn == null) {
conn = ConnectDataBase.getConn();
}
}
public String updateChengji(Chengji chengji) {
PreparedStatement pstmt = null;
String str = "";
try {
if (conn == null) {
this.setConn();
}
pstmt = conn.prepareStatement(
"update chengji set stuCourGrade=? where stuNo=? and courNo=?");
pstmt.setInt(2, course.getCourXuefen());
pstmt.setString(1, course.getCourName());
pstmt.setString(3, course.getCourNo());
pstmt.execute();
str = "sucess";
} catch (Exception ex) {
ex.printStackTrace();
str = "failer";
} finally {
try {
if (pstmt != null) {
pstmt.close();
}
if (conn != null) {
conn.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return str;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?