このメソッドを作成しましたが、メソッドを呼び出そうとすると、null ポインター例外が返されます。誰が何が悪いのか教えてもらえますか? お願い助けて
public Talent SearchTalentQuery(int talentID){
String SearchTalentString = "SELECT * FROM TALENT WHERE TALENTID = "+talentID+";";
Talent talent=null;
try{
//error in select query
if(getOracleXEConnection()!=null){
Statement statement = conn.createStatement();
ResultSet rs = statement.executeQuery(SearchTalentString);
while( rs.next()){
talent.setTalentName(rs.getString("talentname"));
talent.setTalentFocus(rs.getString("maintalentfocus"));
talent.setTalentNationality((rs.getString("nationality")));
talent.setTalentGroup(rs.getString("talentgroup"));
talent.setTalentHiredate(rs.getString("hiredate"));
talent.setTalentAge(Integer.parseInt(rs.getString("age")));
talent.setTalentID(Integer.parseInt(rs.getString("talentid")));
}
rs.close();
statement.close();
conn.close();
return talent;
}
else{
return null;
}
}
catch(SQLException | NumberFormatException e){
e.printStackTrace();
}
return null;