import xyz.wbsite.wsqlite.ObjectClient;
import xyz.wbsite.wsqlite.entity.User;

import java.io.File;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;

public class SqliteTest {
    public static void main(String[] args) {
        try {
            List<Class> arrayList = new ArrayList();
            arrayList.add(User.class);
            ObjectClient h = new ObjectClient(new File("D:\\test.db"),arrayList);

            System.out.println("测试 insert");
            User user = new User();
            user.setName("wangbing");
            user.setPassword("test");
            h.insert(User.class, user);

            System.out.println("测试 select");
            List<User> select = h.select(User.class,1,10);
            System.out.println(select.size());

            System.out.println("测试 update");
            user.setName("==");
            user.setPassword("==");
            int update = h.update(User.class, user);
            System.out.println(update);

            System.out.println("测试 delete");
            int delete = h.delete(User.class,"NAME = '=='");
            System.out.println(delete);

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}