-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added One-Click database export option
- Loading branch information
1 parent
c6ed54f
commit 49ae2ee
Showing
6 changed files
with
138 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/library/assistant/database/export/DatabaseExporter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package library.assistant.database.export; | ||
|
||
import java.awt.Desktop; | ||
import java.io.File; | ||
import java.sql.CallableStatement; | ||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
import javafx.concurrent.Task; | ||
import library.assistant.alert.AlertMaker; | ||
import library.assistant.database.DatabaseHandler; | ||
import library.assistant.util.LibraryAssistantUtil; | ||
|
||
/** | ||
* | ||
* @author Villan | ||
*/ | ||
public class DatabaseExporter extends Task<Boolean> { | ||
|
||
private final File backupDirectory; | ||
|
||
public DatabaseExporter(File backupDirectory) { | ||
this.backupDirectory = backupDirectory; | ||
} | ||
|
||
@Override | ||
protected Boolean call() { | ||
try { | ||
createBackup(); | ||
return true; | ||
} catch (Exception exp) { | ||
AlertMaker.showErrorMessage(exp); | ||
} | ||
return false; | ||
} | ||
|
||
private void createBackup() throws Exception { | ||
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy_MM_dd_hh_mm_ss"); | ||
String backupdirectory = backupDirectory.getAbsolutePath() + File.separator + LocalDateTime.now().format(dateFormat); | ||
try (CallableStatement cs = DatabaseHandler.getInstance().getConnection().prepareCall("CALL SYSCS_UTIL.SYSCS_BACKUP_DATABASE(?)")) { | ||
cs.setString(1, backupdirectory); | ||
cs.execute(); | ||
} | ||
File file = new File(backupdirectory); | ||
LibraryAssistantUtil.openFileWithDesktop(file); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters