데이터베이스 테이블에서 값을 가져 오는 동안 NULL 포인터 예외가 계속 발생합니다 ..... 왜 그 포인터가 널 포인터 예외입니까? 잘못자바의 테이블 열에 null 값을 처리하는 방법은 무엇입니까?
private HashSet getPlayerList() {
HashSet hs = new HashSet();
String soccername = "";
try {
conn = ConnectionProvider.getConnection();
rs = null;
pstmt = null;
String sql = "Select * from Players where deleted = false";
if (conn != null) {
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next()) {
soccername = rs.getString("soccername").trim();// this line giving exception
if (soccername == null || soccername.isEmpty()) {
soccername = rs.getString("name").trim();
}
hs.add(soccername);
}
}
} catch (NamingException ex) {
System.out.println(ex);
} catch (SQLException ex) {
System.out.println(ex);
} finally {
try {
pstmt.close();
rs.close();
conn.close();
} catch (SQLException ex) {
System.out.println(ex);
}
}
return hs;
}
가능한 중복 (HTTP [널 (null) 포인터 예외이며, 내가 그것을 어떻게 해결합니까 무엇?] : // 유래. com/questions/218384/what-is-a-null-pointer-exception-and-how-do-i-fix-it) – Deltharis