It's because your not displaying the name from the database but the name you assigned which is null. You need to replace System.out.println(lg.getName()); with System.out.println(rs.getString("name"));