-
Notifications
You must be signed in to change notification settings - Fork 0
/
SqlExport.java
49 lines (39 loc) · 1.21 KB
/
SqlExport.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* @brief sql export
* @author Yannis Exidaridis <[email protected]>
*/
package albums;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author yannis
*/
public class SqlExport {
public final String EXPORT_FILENAME = "albums.sql";
public String command = null;
public SqlExport() {
Database db = new Database();
Config cfg = new Config();
if (cfg.ReadConfig()) {
command = cfg.get_mysql_exec() + " --user=" + db.get_database_username() + " --password=" + db.get_database_password() + " " + db.get_database_name() + " " + db.get_table() + " -r " + EXPORT_FILENAME;
}
}
/**
* @brief export to sql format
* @return
*/
public Boolean CreateSqlExport() {
try {
Process process = Runtime.getRuntime().exec(command);
int processComplete = process.waitFor();
if (processComplete == 0) {
return true;
}
} catch (IOException | InterruptedException ex) {
Logger.getLogger(SqlExport.class.getName()).log(Level.SEVERE, null, ex);
}
return false;
}
}