package sqlconnect;

import java.util.ArrayList;

public class Add {
    public static void insert(String table,ArrayList<String> value){
        if(Database.Maps.containsKey(table)==false){
            System.err.println("没有找到该表");
            return;
        }
        ArrayList<String> Word=Readclass.getWord(table,value);
        int sz=Word.size();
        StringBuffer sqlQue=new StringBuffer();
        sqlQue.append("insert into "+table+" values (");
        for(int i=0;i<sz;i++){
            sqlQue.append(Word.get(i)+(i==sz-1?")":","));
        }
        try {
            System.err.println(sqlQue.toString());
            Database.state.execute(sqlQue.toString());
            System.out.println("插入成功");
        }catch (Exception e){
            System.err.println("插入失败");
            e.printStackTrace();
        }
    }
}
