/**
* DBUtils练习,增删改查,ResultSetHandler的9个结果处理器
*/publicclassTestDBUtils {@TestpublicvoidtestSelect() throws SQLException {
QueryRunner queryRunner = new QueryRunner(C3P0Util.getDataSource());
List query = queryRunner.query("select * from user where password=?",
new BeanListHandler(User.class), 321);
for (User u : query) {
System.out.println(u);
}
}
@TestpublicvoidtestInsert() throws SQLException {
QueryRunner queryRunner = new QueryRunner(C3P0Util.getDataSource());
queryRunner.update("insert into user(username,password,email,birthday) values(?,?,?,?)",
"老张", "123", "[email protected]", "2013-3-2");
}
@TestpublicvoidtestUpdate() throws SQLException {
QueryRunner queryRunner = new QueryRunner(C3P0Util.getDataSource());
queryRunner.update("update user set username=?,password=? where id=?",
"王婉婉", "321", 2);
}
@TestpublicvoidtestDelete() throws SQLException {
QueryRunner queryRunner = new QueryRunner(C3P0Util.getDataSource());
queryRunner.update("delete from user where id=?",
2);
}
@TestpublicvoidtestBatch() throws SQLException {
QueryRunner queryRunner = new QueryRunner(C3P0Util.getDataSource());
Object[][] objects = new Object[10][4];
for (int i = 0; i < objects.length; i++) {
objects[i][0] = "程啸" + i;
objects[i][1] = "aaa" + i;
objects[i][2] = i + "@q.c";
objects[i][3] = "2017-02-" + i;
}
queryRunner.batch("insert into user(username,password,email,birthday) values(?,?,?,?)", objects);
}
@Test//ArrayHandler适合取1条数据,把这条数据的每列值封装到一个数组中publicvoidtest1() throws SQLException {
QueryRunner qr = new QueryRunner(C3P0Util.getDataSource());
Object[] query = qr.query("select * from user where id=?", new ArrayHandler(), 13);
for (Object o : query)
System.out.println(o);
}
@Test//ArrayListHandler适合取多条数据,把这条数据的每列值封装到一个数组中,把数组封装到List中publicvoidtest2() throws SQLException {
QueryRunner qr = new QueryRunner(C3P0Util.getDataSource());
List
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000777c3290, pid=5632, tid=6656
#
# JRE version: Java(TM) SE Ru
Spring 中提供一些Aware相关de接口,BeanFactoryAware、 ApplicationContextAware、ResourceLoaderAware、ServletContextAware等等,其中最常用到de匙ApplicationContextAware.实现ApplicationContextAwaredeBean,在Bean被初始后,将会被注入 Applicati
在Java项目中,我们通常会自己写一个DateUtil类,处理日期和字符串的转换,如下所示:
public class DateUtil01 {
private SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public void format(Date d
问题描述:
在实现类中的某一或某几个Override方法发生编译错误如下:
Name clash: The method put(String) of type XXXServiceImpl has the same erasure as put(String) of type XXXService but does not override it
当去掉@Over