用處:就是export-db.bat,然後儲存在乙個xml裡面,做資料備份。
適用範圍:springside的dbunit
private static final int buff_size = 16 * 1024;
private logger logger = logge***ctory.getlogger(getclass());
@autowired
private datasource datasource;
/*** 儲存到config配置的目錄下面。
* * @return 壓縮檔案的檔名
*/public file dobackup() 開始備份操作", springsecurityutils.getcurrentusername());
try catch (ioexception e)
******dateformat sdf = new ******dateformat("yyyy-mm-dd_hh-mm-ss");
string title = sdf.format(new date());
file xmlfile = new file(config.sys_backup_path, title + ".xml");
file zipfile = new file(config.sys_backup_path, title + "-bak.zip");
//export to xml
exportdatabase(xmlfile);
//zip it
try catch (ioexception e)
//delete xml
try catch (ioexception e)
logger.debug("{}備份操作成功:{}", springsecurityutils.getcurrentusername(), zipfile.getabsolutepath());
return zipfile;
}// 打包xml
private void zipfile(file xmlfile, file zipfile) throws ioexception
bis.close();
zos.flush();
zos.close();
}private void exportdatabase(file xmlfile) catch (exception e) finally
} catch (sqlexception e) }}
private void exportdatabase(idatabaseconnection connection, file file, boolean streamed, boolean flat)
throws exception
idataset fulldataset = connection.createdataset();
fileoutputstream stream = new fileoutputstream(file);
if (flat)
flatxmldataset.write(fulldataset, stream);
else
//格式化後的xml
xmldataset.write(fulldataset, stream);
stream.close();
}
乙個struts spring的例子
第乙個struts spring的例子 呵呵剛學spring 寫還望各位大蝦指教!配置struts就不用說了吧,如果用myeclipse直接add一下就可以了.接下來就來配置讓它支援spring 可 一,新建專案後,開啟struts confing.xml在後面加人下面 簡單吧!二然後就開始寫我們的...
乙個sql的例子
select dbo.userinfo.username,dbo.userinfo.usertruename,dbo.userinfo.useremail,dbo.userinfo.usermobile,dbo.userinfo.usertelephone,dbo.userinfo.usercar,...
乙個API HOOK的例子
乙個api hook的例子 2010年07月20日 include include 執行緒操作api hinstance hinst 任務例項id hwnd mainfrmhwnd 主視窗控制代碼 hfont globalfont 字型 typedef struct remoteparam 視窗類名...