Home > Database > Mysql Tutorial > body text

请问:mysqldump命令导出mysql后数据表是什么类型的,能 变成excel表格样式的吗?

WBOY
Release: 2016-06-06 09:39:11
Original
1038 people have browsed it

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>
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template