またはsearchO
など、任意のオブジェクトをメソッドに渡すことができるようにしたい。オブジェクトクラスはすべてのスーパークラスであるため、すべてのオブジェクトを受け入れる必要があります。td1.searchO("akash")
td1.searchO(1)
どうすればいいですか?
public boolean searchO(String o ) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException{
Statement st=null;
Connection con=test1.getConnection();
st=con.createStatement();
ResultSet rs=st.executeQuery("select * from `student` where `fname` = '" + o + "' ;");
//System.out.println("full name is "+rs.getString("lname")+" "+rs.getString("fname"));
if(rs.next()==true){
System.out.println("full name is "+rs.getString("lname")+" "+rs.getString("fname"));
return true;
}
else{
return false;
}
}