我试图从 2 个不同的表 member_tbl 和 schedule_tbl 中获取值,其中每个表具有相同的 member_ID。现在当我尝试检索详细信息时。它说 member_ID 不存在。我的代码如下。
public int getMemberDetails(String memberid) {
int oky = 0;
String memberDetails = "SELECT * FROM member_tbl WHERE member_ID = ?";
String scheduleDetails = "SELECT * FROM schedule_tbl WHERE member_ID = ?";
try {
con.connect();
ps = con.con.prepareStatement(memberDetails);
pc = con.con.prepareStatement(scheduleDetails);
ps.setString(1, memberid);
pc.setString(1, memberid);
rs = ps.executeQuery();
rb = pc.executeQuery();
while (rs.next() || rb.next()) {
uID = rs.getString("member_ID");
jdate = rs.getString("joinDate");
surname = rs.getString("lastname");
mname = rs.getString("middlename");
fname = rs.getString("MfirstName");
dob = rs.getString("DOB");
telephone = rs.getString("telephone");
email= rs.getString("Memail");
street = rs.getString("Mstreet");
city = rs.getString("Mcity");
state = rs.getString("Mstate");
country = rs.getString("Mcountry");
memtype = rs.getString("Mtype");
mfee = rs.getString("Mtotal");
photo = rs.getString("mphoto");
bweight = rs.getString("body_weight");
bfat = rs.getString("body_fat");
bmass = rs.getString("body_mass");
bheight = rs.getString("height");
bpressure = rs.getString("blood_pressure");
days = rb.getString("Days");
hour = rb.getString("Hours");
instruct = rb.getString("instructor");
oky = 1;
}
con.con.close();
} catch(SQLException e) {
}
return oky;
}
// This is where i call the method.
private void memIDsearchButtonMouseClicked(java.awt.event.MouseEvent evt) {
try {
mids = memIDsearchField.getText();
sqlQuerry sql = new sqlQuerry();
int ans = sql.getMemberDetails(mids);
if (ans == 1 )
{
idfield.setText(sql.uID);
jdatefield.setText(sql.jdate);
surnamefield.setText(sql.surname);
middlenamefield.setText(sql.mname);
firstnamefield.setText(sql.fname);
dobfield.setText(sql.dob);
phonefield.setText(sql.telephone);
..................................................... ......
但它一直没有返回任何结果集。我不知道我是否做错了什么。几天前它工作得很好,但我不知道出了什么问题。提前致谢。