I am trying to use a String read from a row in an SQL database, but when I do, I get the following NullPointerException :
Exception in thread "main" java.lang.NullPointerException
at ReadCol.data(ReadCol.java:37)
at ReadCol.main(ReadCol.java:50)
My code is shown below...
public String[] array;
ResultSet rs=st.executeQuery("select * from ATTENDANCE");
while(rs.next()){
File file = new File("E:\\eclipse\\workspace\\AutoAttendanceSystem\\res\\AttendanceData.csv");
List<String> lines = Files.readAllLines(file.toPath(), StandardCharsets.UTF_8);
for (String line : lines) {
array = line.split(",");
// This is line 37 :
if(rs.getString(1).equals(array[0]) && rs.getString(7).equals(array[6])){
JOptionPane.showMessageDialog(null, "Can't Update Because record already exist");
}
}
Here is the SQL table's structure :
CREATE TABLE "ATTENDANCE" (
"ATTENDANT_NAME" VARCHAR2(4000),
"ATTENDANT_AGE" NUMBER,
"ATTENDANT_CONTACT_NO" NUMBER,
"ATTENDANT_DEPARTMENT_NAME" VARCHAR2(4000),
"REGISTRATION_NUM" VARCHAR2(50),
"ABSENT_PRESENT" VARCHAR2(4000) DEFAULT 'Absent',
"ATTENDANCE_TIME_DATE" VARCHAR2(4000)
)
And here is an example of a row in that table :
Sun 2016.08.14 at 11:21:43 PM PDT, null, null, Thu 2016.08.18 at 01:58:34 AM PDT, null, Thu 2016.08.18 at 02:13:26 AM PDT, null
What is the problem ?