尚硅谷Maven教程(maven入門+高深,全網(wǎng)無(wú)出其右?。?/h1>

public class BaseDao <T>{
public int[] batch(String sql,Object[][] orderItemParams){
Connection connection = null;
try {
connection = JDBCUtils.getConnection();
return new QueryRunner().batch(
connection,
sql,
orderItemParams
);
} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
//JDBCUtils.release(connection,null);
}
}
public int update(String sql,Object...param){
Connection connection = null;
try {
connection = JDBCUtils.getConnection();
return new QueryRunner().update(
connection,
sql,
param
);
} catch (SQLException e) {
throw new RuntimeException(e);
}finally {
//JDBCUtils.release(connection,null);
}
}
public T getBean(Class<T> clazz,String sql,Object...param){
Connection connection = null;
try {
connection = JDBCUtils.getConnection();
return new QueryRunner().query(
connection,
sql,
new BeanHandler<>(clazz),
param
);
} catch (SQLException e) {
throw new RuntimeException(e);
}finally {
//JDBCUtils.release(connection,null);
}
}
public List<T> getBeanList(Class<T> clazz, String sql, Object...param){
Connection connection = null;
try {
connection = JDBCUtils.getConnection();
return new QueryRunner().query(
connection,
sql,
new BeanListHandler<>(clazz),
param
);
} catch (SQLException e) {
throw new RuntimeException(e);
}finally {
//JDBCUtils.release(connection,null);
}
}
public Long getSize(String sql) throws Exception{
Connection connection = null;
try {
connection = JDBCUtils.getConnection();
return new QueryRunner().query(connection,sql,new ScalarHandler<>());
} catch (SQLException e) {
throw new RuntimeException(e);
}finally {
//JDBCUtils.release(connection,null);
}
}
}