I am uploading a text file using servlets and reading it, and trying to insert into database
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
ServletContext context = getServletContext();
String path = context.getRealPath(file);
File file = new File(path);
FileInputStream in = null;
try {
in = new FileInputStream(uploadFilePath+File.separator+file.getName());
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
while ((strLine = br.readLine()) != null) {
System.out.println(strLine);
decodeAisData(strLine); //it is reading each line but not inserting into database
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
In the decode i have written the database insertion logic, but it is not executing