return "Dragon [id=" + id + ", masterId=" + masterid + ",font-family: Consolas; font-size: 0.917rem"> + name + ", health=" + health + ", lover="
+ lover + ", type=" + type + ", grade=" + grade + "]";
}
}
1.5 开始测试测试比较简单只测了查询
有兴趣的话可以更改配置文件测试不同数据库之间的连接,和对表的其他操作
package com.hx.test;
import static org.junit.Assert.*;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.junit.Test;
import com.hx.basedao.BaseDao;
import com.hx.entity.Dragon;
public class TestJDBC {
public static void main(String[] args) throws IOException {
test();
}
@Test
public static void test() {
String sql = "select * from dragon";
List<Dragon> dList = (List<Dragon>) BaseDao.queryByResultSet(sql, null, Dragon.class);
for (Dragon dragon : dList) {
System.out.println(dragon.toString());
}
}
@Test
public static void test2() {
String sql = "select * from dragon";