📄 mysqlconsole.java
字号:
package console.mysql;
import java.io.IOException;
import console.Operation;
/**
* @author Allan(刘新福)
* @version 1.0
*/
public class MySQLConsole {
public static void main(String[] args) throws IOException {
if (args.length < 5) {
System.out
.println("Usage: java console.MySQLConsole <serverIP> <serverPort> <databaseName> <userName> <password> [isolation]");
System.exit(0);
}
Operation operation = null;
try {
if (args.length == 5) {
operation = new MySQLOperation(args[0], args[1], args[2],
args[3], args[4]);
} else {
operation = new MySQLOperation(args[0], args[1], args[2],
args[3], args[4], Integer.parseInt(args[5]));
}
} catch (Exception e) {
System.exit(0);
}
System.out
.println("Welcome to MySQL console tools version1.0. Using isolation: "
+ operation.getTransactionIsolation());
System.out.println("Author:Allan Liu");
System.out.println("Contact: allanlxf@hotmail.com");
System.out.println("quit; or exit; to end program");
System.out.print("MySQL>");
StringBuffer sql = new StringBuffer();
while (true) {
char ch = ';';
while ((ch = (char) System.in.read()) != ';') {
sql.append(ch);
}
if (sql.toString().indexOf("quit") != -1
|| sql.toString().indexOf("exit") != -1) {
break;
} else {
try {
operation.execute(sql.toString());
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
sql.delete(0, sql.length());
System.out.print("MySQL>");
}
operation.release();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -