1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| private List<Extraction> dataToLines(List<String[]>data) throws java.text.ParseException, IOException{ final List<Extraction> lines = new ArrayList<Extraction>();
Session s = HibernateUtil.getSession();
Transaction tx = s.beginTransaction();
try {
try {
List<Extraction> listLigne = (List<Extraction>) s.createQuery("from Extraction").list();
for(Extraction ligne : listLigne) {
s.delete(ligne);
}
} catch (Exception e) {
e.printStackTrace();
}
String filePath = new File(lien + "\\" + extract.getNomExtract()).getAbsolutePath();
filePath.concat(extract.getNomExtract());
File file = new File(filePath);
fis = new FileInputStream(file);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date jour = new Date(file.lastModified());
System.out.println(jour);
extract.setDateImport(jour);
s.update(extract);
.....................
}
tx.commit();
}catch(ParseException e) {
e.printStackTrace();
tx.rollback();
}finally {
System.err.println("Import terminé");
s.close();
fis.close();
}
return lines;
} |
Partager