mysqlexcel数据classstring
public class BackupHandlerImpl implements BackupHandler {
<code>//获得mysql bin的目录private String getMySQLBin(GlobalContext ctx) { return ctx.getMySQLHome() + MySQLUtil.MYSQL_HOME_BIN + File.separator;}public void dumpDatabase(GlobalContext ctx, Database db, File targetFile) { StringBuffer dumpCommand = new StringBuffer(); //注意, 需要为命令加入双引号, 如果没有双引号, mysql安装目录有空格将不能正常导出 dumpCommand.append('"' + getMySQLBin(ctx)); //加入mysqldump命令 dumpCommand.append(MySQLUtil.MYSQLDUMP_COMMAND + '"'); //加入各个信息 //为命令加入-u -p -h参数 getExecuteCommand(dumpCommand, db.getServerConnection()); dumpCommand.append(" --force --databases " + db.getDatabaseName() + " > "); //如果导出的路径有空格将不能正常导出, 因此注意需要为路径加入引号 dumpCommand.append('"' + targetFile.getAbsolutePath() + '"'); System.out.println(dumpCommand.toString()); //启动执行导出的线程 CommandThread thread = new CommandThread(dumpCommand.toString()); thread.start();}public void dumpTable(GlobalContext ctx, List<tabledata> tables, Database db, File targetFile) { StringBuffer dumpCommand = new StringBuffer(); StringBuffer tableNames = new StringBuffer(); //得到所有表名字符串 for (TableData table : tables) tableNames.append(table.getName() + " "); dumpCommand.append('"' + getMySQLBin(ctx)); //加入mysqldump命令 dumpCommand.append(MySQLUtil.MYSQLDUMP_COMMAND + '"'); //为命令加入-u -p -h参数 getExecuteCommand(dumpCommand, db.getServerConnection()); dumpCommand.append(" --databases " + db.getDatabaseName()); dumpCommand.append(" --tables " + tableNames.toString() + " > "); dumpCommand.append('"' + targetFile.getAbsolutePath() + '"'); System.out.println(dumpCommand.toString()); new CommandThread(dumpCommand.toString()).start();}public void executeSQLFile(GlobalContext ctx, Database db, File sqlFile) { StringBuffer dumpCommand = new StringBuffer(); dumpCommand.append('"' + getMySQLBin(ctx)); dumpCommand.append(MySQLUtil.MYSQL_COMMAND + '"'); //为命令加入-u -p -h参数 getExecuteCommand(dumpCommand, db.getServerConnection()); dumpCommand.append(" -D" + db.getDatabaseName()); dumpCommand.append(" </tabledata></code>