空の変数を渡し続けるため、変数を別のクラスに渡すのに問題があります。
id
メソッドからの値を取得し、メソッド内にsearch()
転送したい...class foo
total
クラスBoo
:
//method inside of class boo
public void search(){
try{
String id = searchBox.getText();
String idNum="";
rs = stat.executeQuery("Select * from students where idNum='"+id+"'");
while(rs.next()){
idNum = rs.getString("idNum");
}//while
Members members = new Members();
setVisible(false);
members.setIdVal(id);
}catch(Exception e){
System.out.println("Error: "+e);
}
}//search
クラスFoo
:
// methods inside Foo
public void total(){
System.out.println("Get: "+getIdVal());
try{
rs2 = stat2.executeQuery("SELECT * FROM paymentRecord where idNum ='"+getIdVal()+"';");
}catch(Exception e){
System.out.println("Total Error: "+e);
}//
}//total
public void setIdVal(String val){
this.val = val;
}//get the id
public String getIdVal(){
//System.out.println("Inputted ID:" + val);
return this.val;
}//get the id