1 package async; 2 3 import dinamica.*; 4 import java.io.File ; 5 6 17 public class RegisterFile extends GenericTransaction 18 { 19 20 23 public int service(Recordset inputParams) throws Throwable 24 { 25 super.service(inputParams); 26 27 Db db = getDb(); 28 29 String sql1 = getSQL(getResource("insert.sql"), inputParams); 31 db.exec(sql1); 32 33 String sql2 = getSQL(getResource("query.sql"), inputParams); 35 Recordset rs = db.get(sql2); 36 rs.next(); 37 String taskID = rs.getString("id"); 38 39 java.io.File f = new File (inputParams.getString("file")); 41 42 String newFileName = getContext().getAttribute("javax.servlet.context.tempdir").toString() 44 + java.io.File.separator + rs.getString("id") + ".dat"; 45 46 f.renameTo(new File (newFileName)); 48 49 getSession().setAttribute("task.id", taskID); 51 52 Thread t = new Thread (new BatchProcess(taskID, newFileName, this.getDataSource(), getResource("p-insert.sql")), "BatchProcess" + taskID); 54 t.start(); 55 56 return 0; 57 } 58 59 } 60 | Popular Tags |