자바 호출 my sql 명령 내 보 내기 데이터베이스 가 져 오기

1317 단어 JavaMySQLSQLCC++


package com.db.tools;
/**
 *      ,            OK,
 *    bug,   [email protected]   !
 */
public class SqlControl {

	//      
	public static void backup(String dbName, String filePath) {
		try {
			@SuppressWarnings("unused")
			Process process = Runtime.getRuntime().exec(
					"cmd  /c  mysqldump -uroot -psa " + dbName + " > "
							+ filePath + "/" + new java.util.Date().getTime()
							+ ".sql");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			System.out.println("     ");
			e.printStackTrace();
		}
	}

	@SuppressWarnings("unused")
	//      
	public static void load(String dbName, String filePath) {
		try {
			@SuppressWarnings("unused")
			Process process = Runtime.getRuntime().exec(
					"cmd  /c  mysql -uroot -psa " + dbName + " < " + filePath);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			System.out.println("     ");
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		try {
			// backup("mysql2009","d:/");
			load("test", "d:/1259138711453.sql");
			System.out.println("ok");
		} catch (Exception e) {
			// TODO: handle exception
			e.getMessage();
		}

	}
}




좋은 웹페이지 즐겨찾기