org.h2.store.fs.FileUtils Java Examples

The following examples show how to use org.h2.store.fs.FileUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CompactLocalH2.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public boolean execute() throws Exception {
	DataServer server = Config.currentNode().getData();
	if (null == server) {
		logger.print("not config dataServer.");
		return false;
	}
	if (!BooleanUtils.isTrue(server.getEnable())) {
		logger.print("data server not enable.");
		return false;
	}
	if (Servers.dataServerIsRunning()) {
		logger.print("data server is running, must stop data server first.");
		return false;
	}
	/* 需要注入驱动程序 */
	// Class.forName(SlicePropertiesBuilder.driver_h2).newInstance();
	DriverManager.registerDriver(new org.h2.Driver());
	logger.print("compact data start at {}.", DateTools.format(start));
	String dir = StringUtils.replace(Config.base(), "\\", "/") + "/local/repository/data";
	String url = "jdbc:h2:" + dir + "/X;FILE_LOCK=NO";
	String backup = dir + "/backup.sql";
	Script.process(url, "sa", Config.token().getPassword(), backup, "", "");
	DeleteDbFiles.execute(dir, "X", true);
	RunScript.execute(url, "sa", Config.token().getPassword(), backup, null, false);
	FileUtils.delete(backup);
	Date end = new Date();
	System.out.println(String.format("compact data completed at %s, elapsed:%dms.", DateTools.format(end),
			end.getTime() - start.getTime()));
	return true;
}
 
Example #2
Source File: TaskanaRoleConfigAccTest.java    From taskana with Apache License 2.0 4 votes vote down vote up
private void deleteFile(String propertiesFileName) {
  File f = new File(propertiesFileName);
  if (f.exists() && !f.isDirectory()) {
    FileUtils.delete(propertiesFileName);
  }
}
 
Example #3
Source File: TaskanaConfigAccTest.java    From taskana with Apache License 2.0 4 votes vote down vote up
private void deleteFile(String propertiesFileName) {
  File f = new File(propertiesFileName);
  if (f.exists() && !f.isDirectory()) {
    FileUtils.delete(propertiesFileName);
  }
}