Note that there are some explanatory texts on larger screens.

plurals
  1. POSerilization data in foramt its getting NullPointerException
    text
    copied!<p>I have written some code to display the data in some format in file </p> <pre><code>public List&lt;TimeSheetVO&gt; getEmployeedetails(Connection con2, java.sql.Date dbdate) { timesheetlist=new ArrayList&lt;TimeSheetVO&gt;(); try { String query = SQLutilConstants.GET_TIMESHEET; psmt=con2.prepareStatement(query); psmt.setDate(1,dbdate ); rs=psmt.executeQuery(); while(rs.next()) { TimeSheetVO timeSheetVO=new TimeSheetVO(); timeSheetVO.setEMP_ID(rs.getString("EMP_ID")); //timeSheetVO.setATTENDANCE_DATE(rs.getString("ATTENDANCE_DATE").replaceAll("[-+.^:,]", "")); String attendance= rs.getString("ATTENDANCE_DATE"); String[] splitattendance=attendance.split("-"); timeSheetVO.setATTENDANCE_DATE(splitattendance[2]+splitattendance[1]+splitattendance[0]); String intimetime= rs.getString("IN_TIME"); String[] splitintime=intimetime.split(":"); timeSheetVO.setIN_TIME(splitintime[0]+splitintime[1]); String outtime=rs.getString("OUT_TIME"); String[] splitouttime=outtime.split(":"); timeSheetVO.setOUT_TIME(splitouttime[0]+splitouttime[1]); System.out.println("timesheetVo"+timeSheetVO.getATTENDANCE_DATE()); timesheetlist.add(timeSheetVO); } } catch(Exception e) { e.printStackTrace(); } return timesheetlist; } </code></pre> <p>Here am using one more <strong>method</strong> and passing <strong>timesheetlist</strong> as <strong>timesheetlist2</strong>: But here displaying only one row remaining rows are not displayed for that corresponding <strong>Attendancedate</strong> getting <strong>NullPointerException</strong></p> <pre><code>public String getTimesheet(List&lt;TimeSheetVO&gt; timesheetlist2, java.sql.Date dbdate) { try { String fieloc=MessageConstants.timesheetpath; File file=new File(fieloc+dbdate+".txt"); FileWriter fw = new FileWriter(file.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); for(TimeSheetVO time: timesheetlist2) { bw.write(time+" "); bw.newLine(); bw.flush(); path=file.getAbsolutePath(); } bw.close(); } catch(Exception e) { e.printStackTrace(); } return path; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload