以下 LOGINFORM 类存储用于登录 GUI 的正确用户名和密码。
登录课程....
public class LoginForm extends javax.swing.JFrame {
String username;
String password;
//rest of code here
我如何检索要在该行中另一个类的准备语句中使用的 Loginform 用户名和密码(“SELECT * FROM AcademicInfo where Email=? and Password=?”);替换 ? ,这将使我能够从 sql 数据库中获取特定字段?
检索类....
public void retrieveAcademic() {
try {
pst = con.prepareStatement("SELECT * FROM AcademicInfo where Username=? and Password=?");
rs = pst.executeQuery();
while (rs.next()) {
title = (rs.getString(2));
forename = (rs.getString(3));
surname = (rs.getString(4));
role = (rs.getString(5));
room = (rs.getString(6));
page = (rs.getString(7));
hours = (rs.getString(8));
phone = (rs.getString(9));
mobile = (rs.getString(10));
email = (rs.getString(11));
} //end while
}