File upload and data import

zhaozj2021-02-16  101

public void doImport (Context ctx) throws ActionException {String tableName = "imei_black_list"; if (JString.isNull (tableName)) return; Table t = new Table (tableName);. List fileItems = (List) ctx.getRequest () getAttribute ("Form-Data"); if (fileitems == null) return; iterator it = fileitems.ITERATOR (); hashtable results = new hashtable (); while (ore) {fileItem item = (fileItem) iter .next (); IF (item.isformfield ()) Continue; string tmp = getTempFile (); list records; try {item.write (tmp); // Import Database RECORDS = fileRegister.getname ()) .process (TMP); int UC = TableUTil.Load (T, Records); log (ctx.getRequest (), "Data Maintenance: Upload Data to" TgetLabel ());} Catch (Exception E) {E .printstacktrace (); finally {records = null;}}

}

/ ** * Load data to the specified table * @Param T * @Param Records * @return * @Throws SQLEXCEPTION * / PUBLIC Static Int LOAD (TABLE T, LIST RECORDS) THROWS Exception {IF (t == null || Records == null || Records.size () == 0) Return 0; list fields = t.Getfields (); if (fields == null) {FillTable (t); fields = t.Getfields ();} string SQL = GetInsertsql (T); connection conn = null; preparedStatement ps = null; Field Field; try {conn = getConnection (); conn.setautocommit (false); ps = conn.preparestatement (SQL); for (int RC = 0 RC

转载请注明原文地址:https://www.9cbs.com/read-10261.html

New Post(0)