📄 sql.java
字号:
import java.io.*;
public class SQL {
public SQL() {
}
public static void main(String[] args) throws Exception{
Interpreter interpreter = new Interpreter("quit;");
Catalog catalog = new Catalog();
BufferManager buffer = new BufferManager();
IndexManager index = new IndexManager(buffer);
RecordManager record = new RecordManager(buffer, index);
API api = new API(index, record, catalog);
String command = new String("");
System.out.print("SQL>");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
while(true){
String com= br.readLine();
while(com!=null){
int pos=0;
while(com!=null){
pos = com.indexOf(";");
if(pos>=0){
command = command+"\n"+com.substring(0,pos+1);
interpreter.init(command);
if(catalog.test(interpreter)){
if(api.exec(interpreter))
System.out.println("execute successfully");
else{
System.out.println("execute failed");
}
}
else{
if(interpreter.mean == 0)
;
else
System.out.println("出错啦,请确保各属性和表名正确");
}
System.out.print("SQL>");
if(pos!=com.length()-1){
command = com.substring(pos,com.length());
}
else
command = new String("");
break;
}
System.out.print("SQL>");
command = command + "\n"+com;
com = br.readLine();
}
com = br.readLine();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -