62,614
社区成员
发帖
与我相关
我的任务
分享
private static void importSql(String installFilesPath, String[] sqlPaths) throws Exception {
for(String sqlPath : sqlPaths) {
// String cmd = "mysql -u "+USER+" -p"+PASSWORD+"\nsource "+installFilesPath+sqlPath+";\nexit;\n";
String cmd = "mysql -uroot -p123456 </lqa.sql";
System.out.println(cmd);
// System.out.println(new String(cmd.getBytes("GB2312"),"UTF-8"));
// System.out.println(new String(cmd.getBytes("UTF-8"), "UTF-8"));
Process process = Runtime.getRuntime().exec(cmd);
// Process process = Runtime.getRuntime().exec("mysql",
// new String[]{"-uroot", "-p123456", "</lqa.sql"});
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String output = null;
while ((output = bufferedReader.readLine()) != null){
System.out.println(output);
}
process.waitFor();
break;
}
}
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Usage: mysql [OPTIONS] [database]
-?, --help Display this help and exit.
-I, --help Synonym for -?
--auto-rehash Enable automatic rehashing. One doesn't need to use
'rehash' to get table and field completion, but startup
and reconnecting may take a longer time. Disable with
--disable-auto-rehash.
-A, --no-auto-rehash
No automatic rehashing. One has to use 'rehash' to get
......以后忽略