问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

直径25的钢筋在基础梁如何连接

发布网友 发布时间:2022-04-09 03:32

我来回答

4个回答

懂视网 时间:2022-04-09 07:53

public class MyPool { private int init_count = 3; // 初始化连接数目 private int max_count = 6; // 最大连接数 private int current_count = 0; // 记录当前使用连接数 // 连接池 (存放所有的初始化连接) private LinkedList<Connection> pool = new LinkedList<Connection>(); //1. 构造函数中,初始化连接放入连接池 public MyPool() { // 初始化连接 for (int i=0; i<init_count; i++){ // 记录当前连接数目 current_count++; // 创建原始的连接对象 Connection con = createConnection(); // 把连接加入连接池 pool.addLast(con); } } //2. 创建一个新的连接的方法 private Connection createConnection(){ try { Class.forName("com.mysql.jdbc.Driver"); // 原始的目标对象 final Connection con = DriverManager.getConnection("jdbc:mysql:///jdbc_demo", "root", "root"); /**********对con对象代理**************/ // 对con创建其代理对象 Connection proxy = (Connection) Proxy.newProxyInstance( con.getClass().getClassLoader(), // 类加载器 //con.getClass().getInterfaces(), // 当目标对象是一个具体的类的时候 new Class[]{Connection.class}, // 目标对象实现的接口 new InvocationHandler() { // 当调用con对象方法的时候, 自动触发事务处理器 @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { // 方法返回值 Object result = null; // 当前执行的方法的方法名 String methodName = method.getName(); // 判断当执行了close方法的时候,把连接放入连接池 if ("close".equals(methodName)) { System.out.println("begin:当前执行close方法开始!"); // 连接放入连接池 pool.addLast(con); System.out.println("end: 当前连接已经放入连接池了!"); } else { // 调用目标对象方法 result = method.invoke(con, args); } return result; } } ); return proxy; } catch (Exception e) { throw new RuntimeException(e); } } //3. 获取连接 public Connection getConnection(){ // 3.1 判断连接池中是否有连接, 如果有连接,就直接从连接池取出 if (pool.size() > 0){ current_count++; return pool.removeFirst(); } // 3.2 连接池中没有连接: 判断,如果没有达到最大连接数,创建; if (current_count < max_count) { // 记录当前使用的连接数 current_count++; // 创建连接 return createConnection(); } // 3.3 如果当前已经达到最大连接数,抛出异常 throw new RuntimeException("当前连接已经达到最大连接数目 !"); } //4. 释放连接 public void realeaseConnection(Connection con) { // 4.1 判断: 池的数目如果小于初始化连接,就放入池中 if (pool.size() < init_count){ pool.addLast(con); } else { try { // 4.2 关闭 current_count--; con.close(); } catch (SQLException e) { throw new RuntimeException(e); } } } public static void main(String[] args) throws SQLException { MyPool pool = new MyPool(); System.out.println("当前连接: " + pool.current_count); // 3 // 使用连接 pool.getConnection(); pool.getConnection(); Connection con4 = pool.getConnection(); Connection con3 = pool.getConnection(); Connection con2 = pool.getConnection(); Connection con1 = pool.getConnection(); // 释放连接, 连接放回连接池 // pool.realeaseConnection(con1); /* * 希望:当关闭连接的时候,要把连接放入连接池!【当调用Connection接口的close方法时候,希望触发pool.addLast(con);操作】 * 把连接放入连接池 * 解决1:实现Connection接口,重写close方法 * 解决2:动态代理 */ con1.close(); // 再获取 pool.getConnection(); System.out.println("连接池:" + pool.pool.size()); // 0 System.out.println("当前连接: " + pool.current_count); // 3 } }

代理的总结:

使用代理,可以在不实现接口的情况,对接口的方法进行扩展,添加额外的用户需要的业务逻辑!

DBCP连接池

概述:

Sun公司约定: 如果是连接池技术,需要实现一个接口!
javax.sql.DataSource;

连接池:

DBCP
C3P0

DBCP连接池:

DBCP 是 Apache 软件基金组织下的开源连接池实现,使用DBCP数据源,应用程序应在系统中增加如下两个 jar 文件:

? Commons-dbcp.jar:连接池的实现
? Commons-pool.jar:连接池实现的依赖库

Tomcat 的连接池正是采用该连接池来实现的。该数据库连接池既可以与应用服务器整合使用,也可由应用程序独立使用。

核心类:

BasicDataSource

使用步骤

? 引入jar文件
commons-dbcp-1.4.jar
commons-pool-1.5.6.jar

配置方式实现DBCP连接池, 配置文件中的key与BaseDataSouce中的属性一样:

db.properties
url=jdbc:mysql:///jdbc_demo
driverClassName=com.mysql.jdbc.Driver
username=root
password=root
initialSize=3
maxActive=6
maxIdle=3000

使用:

public class App_DBCP {

 // 1. 硬编码方式实现连接池
 @Test
 public void testDbcp() throws Exception {
 // DBCP连接池核心类
 BasicDataSource dataSouce = new BasicDataSource();
 // 连接池参数配置:初始化连接数、最大连接数 / 连接字符串、驱动、用户、密码
 dataSouce.setUrl("jdbc:mysql:///jdbc_demo");  //数据库连接字符串
 dataSouce.setDriverClassName("com.mysql.jdbc.Driver"); //数据库驱动
 dataSouce.setUsername("root");    //数据库连接用户
 dataSouce.setPassword("root");    //数据库连接密码
 dataSouce.setInitialSize(3); // 初始化连接
 dataSouce.setMaxActive(6); // 最大连接
 dataSouce.setMaxIdle(3000); // 最大空闲时间

 // 获取连接
 Connection con = dataSouce.getConnection();
 con.prepareStatement("delete from admin where id=3").executeUpdate();
 // 关闭
 con.close();
 }

 @Test
 // 2. 【推荐】配置方式实现连接池 , 便于维护
 public void testProp() throws Exception {
 // 加载prop配置文件
 Properties prop = new Properties();
 // 获取文件流
 InputStream inStream = App_DBCP.class.getResourceAsStream("db.properties");
 // 加载属性配置文件
 prop.load(inStream);
 // 根据prop配置,直接创建数据源对象
 DataSource dataSouce = BasicDataSourceFactory.createDataSource(prop);

 // 获取连接
 Connection con = dataSouce.getConnection();
 con.prepareStatement("delete from admin where id=4").executeUpdate();
 // 关闭
 con.close();
 }
}

C3P0

C3P0连接池:

最常用的连接池技术!Spring框架,默认支持C3P0连接池技术!

C3P0连接池,核心类:

CombopooledDataSource ds;

使用:

1. 下载,引入jar文件: c3p0-0.9.1.2.jar
2. 使用连接池,创建连接
 a) 硬编码方式
 b) 配置方式(xml)

案例:

public class App {

 @Test
 //1. 硬编码方式,使用C3P0连接池管理连接
 public void testCode() throws Exception {
 // 创建连接池核心工具类
 ComboPooledDataSource dataSource = new ComboPooledDataSource();
 // 设置连接参数:url、驱动、用户密码、初始连接数、最大连接数
 dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/jdbc_demo");
 dataSource.setDriverClass("com.mysql.jdbc.Driver");
 dataSource.setUser("root");
 dataSource.setPassword("root");
 dataSource.setInitialPoolSize(3);
 dataSource.setMaxPoolSize(6);
 dataSource.setMaxIdleTime(1000);

 // ---> 从连接池对象中,获取连接对象
 Connection con = dataSource.getConnection();
 // 执行更新
 con.prepareStatement("delete from admin where id=7").executeUpdate();
 // 关闭
 con.close();
 }

 @Test
 //2. XML配置方式,使用C3P0连接池管理连接
 public void testXML() throws Exception {
 // 创建c3p0连接池核心工具类
 // 自动加载src下c3p0的配置文件【c3p0-config.xml】
 ComboPooledDataSource dataSource = new ComboPooledDataSource();// 使用默认的配置

 // 获取连接
 Connection con = dataSource.getConnection();
 // 执行更新
 con.prepareStatement("delete from admin where id=5").executeUpdate();
 // 关闭
 con.close();

 }
}

配置方式:

<c3p0-config>
 <default-config>
 <property name="jdbcUrl">jdbc:mysql://localhost:3306/jdbc_demo
 </property>
 <property name="driverClass">com.mysql.jdbc.Driver</property>
 <property name="user">root</property>
 <property name="password">root</property>
 <property name="initialPoolSize">3</property>
 <property name="maxPoolSize">6</property>
 <property name="maxIdleTime">1000</property>
 </default-config>

 <named-config name="oracle_config">
 <property name="jdbcUrl">jdbc:mysql://localhost:3306/jdbc_demo</property>
 <property name="driverClass">com.mysql.jdbc.Driver</property>
 <property name="user">root</property>
 <property name="password">root</property>
 <property name="initialPoolSize">3</property>
 <property name="maxPoolSize">6</property>
 <property name="maxIdleTime">1000</property>
 </named-config>
</c3p0-config>

重写Utils

public class JdbcUtils {

 /**
 * 1. 初始化C3P0连接池
 */
 private static DataSource dataSource;
 static {
 dataSource = new ComboPooledDataSource();
 }

 /**
 * 2. 创建DbUtils核心工具类对象
 */
 public static QueryRunner getQueryRuner(){
 // 创建QueryRunner对象,传入连接池对象
 // 在创建QueryRunner对象的时候,如果传入了数据源对象;
 // 那么在使用QueryRunner对象方法的时候,就不需要传入连接对象;
 // 会自动从数据源中获取连接(不用关闭连接)
 return new QueryRunner(dataSource);
 }
}

分页技术实践

分页技术:
JSP页面,用来显示数据! 如果数据有1000条,分页显示,每页显示10条,共100页; 好处: 利于页面布局,且显示的效率高!

分页关键点:

  1. 分页SQL语句;
  2. 后台处理: dao/service/servlet/JSP

实现步骤:

0. 环境准备
 a) 引入jar文件及引入配置文件
 i. 数据库驱动包
 ii. C3P0连接池jar文件 及 配置文件
 iii. DbUtis组件: QueryRunner qr = new QueryRuner(dataSouce);
 qr.update(sql);
b) 公用类: JdbcUtils.java
 1. 先设计:PageBean.java
 2. Dao接口设计/实现: 2个方法
 3. Service/servlet
 4. JSP

entity:

public class Employee {

 private int empId;  // 员工id
 private String empName; // 员工名称
 private int dept_id; // 部门id

 public int getEmpId() {
 return empId;
 }
 public void setEmpId(int empId) {
 this.empId = empId;
 }
 public String getEmpName() {
 return empName;
 }
 public void setEmpName(String empName) {
 this.empName = empName;
 }
 public int getDept_id() {
 return dept_id;
 }
 public void setDept_id(int deptId) {
 dept_id = deptId;
 } 
}

Dao:

public interface IEmployeeDao {

 /**
 * 分页查询数据
 */
 public void getAll(PageBean<Employee> pb);

 /**
 * 查询总记录数
 */
 public int getTotalCount();
}

DaoImpl:

public class EmployeeDao implements IEmployeeDao {

 public void getAll(PageBean<Employee> pb) {

 //2. 查询总记录数; 设置到pb对象中
 int totalCount = this.getTotalCount();
 pb.setTotalCount(totalCount);

 /*
  * 问题: jsp页面,如果当前页为首页,再点击上一页报错!
  *  如果当前页为末页,再点下一页显示有问题!
  * 解决:
  * 1. 如果当前页 <= 0; 当前页设置当前页为1;
  * 2. 如果当前页 > 最大页数; 当前页设置为最大页数
  */
 // 判断
 if (pb.getCurrentPage() <=0) {
  pb.setCurrentPage(1);   // 把当前页设置为1
 } else if (pb.getCurrentPage() > pb.getTotalPage()){
  pb.setCurrentPage(pb.getTotalPage()); // 把当前页设置为最大页数
 }

 //1. 获取当前页: 计算查询的起始行、返回的行数
 int currentPage = pb.getCurrentPage();
 int index = (currentPage -1 ) * pb.getPageCount(); // 查询的起始行
 int count = pb.getPageCount();    // 查询返回的行数


 //3. 分页查询数据; 把查询到的数据设置到pb对象中
 String sql = "select * from employee limit ?,?";

 try {
  // 得到Queryrunner对象
  QueryRunner qr = JdbcUtils.getQueryRuner();
  // 根据当前页,查询当前页数据(一页数据)
  List<Employee> pageData = qr.query(sql, new BeanListHandler<Employee>(Employee.class), index, count);
  // 设置到pb对象中
  pb.setPageData(pageData);

 } catch (Exception e) {
  throw new RuntimeException(e);
 }
 }

service:

public interface IEmployeeService {

 /**
 * 分页查询数据
 */
 public void getAll(PageBean<Employee> pb);
}

serviceimpl:

public class EmployeeService implements IEmployeeService {

 // 创建Dao实例
 private IEmployeeDao employeeDao = new EmployeeDao();

 public void getAll(PageBean<Employee> pb) {
 try {
  employeeDao.getAll(pb);
 } catch (Exception e) {
  throw new RuntimeException(e);
 }
 }

}

servlet:

public class IndexServlet extends HttpServlet {
 // 创建Service实例
 private IEmployeeService employeeService = new EmployeeService();
 // 跳转资源
 private String uri;

 public void doGet(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, IOException {

 try {
  //1. 获取“当前页”参数; (第一次访问当前页为null) 
  String currPage = request.getParameter("currentPage");
  // 判断
  if (currPage == null || "".equals(currPage.trim())){
  currPage = "1"; // 第一次访问,设置当前页为1;
  }
  // 转换
  int currentPage = Integer.parseInt(currPage);

  //2. 创建PageBean对象,设置当前页参数; 传入service方法参数
  PageBean<Employee> pageBean = new PageBean<Employee>();
  pageBean.setCurrentPage(currentPage);

  //3. 调用service 
  employeeService.getAll(pageBean); // 【pageBean已经被dao填充了数据】

  //4. 保存pageBean对象,到request域中
  request.setAttribute("pageBean", pageBean);

  //5. 跳转 
  uri = "/WEB-INF/list.jsp";
 } catch (Exception e) {
  e.printStackTrace(); // 测试使用
  // 出现错误,跳转到错误页面;给用户友好提示
  uri = "/error/error.jsp";
 }
 request.getRequestDispatcher(uri).forward(request, response);

 }

 public void doPost(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, IOException {
 this.doGet(request, response);
 }

}

PageBean:

public class PageBean<T> {
 private int currentPage = 1; // 当前页, 默认显示第一页
 private int pageCount = 4; // 每页显示的行数(查询返回的行数), 默认每页显示4行
 private int totalCount; // 总记录数
 private int totalPage; // 总页数 = 总记录数 / 每页显示的行数 (+ 1)
 private List<T> pageData; // 分页查询到的数据

 // 返回总页数
 public int getTotalPage() {
 if (totalCount % pageCount == 0) {
  totalPage = totalCount / pageCount;
 } else {
  totalPage = totalCount / pageCount + 1;
 }
 return totalPage;
 }
 public void setTotalPage(int totalPage) {
 this.totalPage = totalPage;
 }

 public int getCurrentPage() {
 return currentPage;
 }
 public void setCurrentPage(int currentPage) {
 this.currentPage = currentPage;
 }
 public int getPageCount() {
 return pageCount;
 }
 public void setPageCount(int pageCount) {
 this.pageCount = pageCount;
 }
 public int getTotalCount() {
 return totalCount;
 }
 public void setTotalCount(int totalCount) {
 this.totalCount = totalCount;
 }

 public List<T> getPageData() {
 return pageData;
 }
 public void setPageData(List<T> pageData) {
 this.pageData = pageData;
 }
}

jsp:

<html>
 <head>

 <title>分页查询数据</title>
 <meta http-equiv="pragma" content="no-cache">
 <meta http-equiv="cache-control" content="no-cache">
 <meta http-equiv="expires" content="0"> 
 </head>

 <body>
 <table border="1" width="80%" align="center" cellpadding="5" cellspacing="0">
 <tr>
  <td>序号</td>
  <td>员工编号</td>
  <td>员工姓名</td>
 </tr>
 <!-- 迭代数据 -->
 <c:choose>
  <c:when test="${not empty requestScope.pageBean.pageData}">
  <c:forEach var="emp" items="${requestScope.pageBean.pageData}" varStatus="vs">
   <tr>
   <td>${vs.count }</td>
   <td>${emp.empId }</td>
   <td>${emp.empName }</td>
   </tr>
  </c:forEach>
  </c:when>
  <c:otherwise>
  <tr>
   <td colspan="3">对不起,没有你要找的数据</td>
  </tr>
  </c:otherwise>
 </c:choose>

 <tr>
  <td colspan="3" align="center">
  当前${requestScope.pageBean.currentPage }/${requestScope.pageBean.totalPage }页   

  <a href="${pageContext.request.contextPath }/index?currentPage=1">首页</a>
  <a href="${pageContext.request.contextPath }/index?currentPage=${requestScope.pageBean.currentPage-1}">上一页 </a>
  <a href="${pageContext.request.contextPath }/index?currentPage=${requestScope.pageBean.currentPage+1}">下一页 </a>
  <a href="${pageContext.request.contextPath }/index?currentPage=${requestScope.pageBean.totalPage}">末页</a>
  </td>
 </tr>

 </table>
 </body>
</html>

25、连接池(DBCP、C3P0)、动态代理与分页技术

标签:

热心网友 时间:2022-04-09 05:01

根据图纸要求,现在一般配采用的是钢筋机械连接,有直螺纹套筒,市场上常用的是剥肋滚轧直螺纹套筒,性价比高,连接性能好,施工简单方便。
搭接最简单,但是浪费钢筋,造价高。
还有墩粗直螺纹连接、冷挤压套筒连接都可以,但是现在很少用,施工复杂,套筒单价高。

热心网友 时间:2022-04-09 06:19

直螺纹比较常见,绑扎也可以

热心网友 时间:2022-04-09 07:54

  直径25的钢筋在基础梁的连接接头使用规定:
  (1)直径大于12mm以上的钢筋,应优先采用焊接接头或机械连接接头。
  (2)当受拉钢筋的直径大于28mm及受压钢筋的直径大于32mm时,不宜采用绑扎搭接接头。
  (3)轴心受拉及小偏心受拉杆件(如桁架和拱的拉杆)的纵向受力钢筋不得采用绑扎搭接接头。
  (4)直接承受动力荷载的结构构件中,其纵向受拉钢筋不得采用绑扎搭接接头。
  混凝土结构设计规范有下面一个说法:
  需进行疲劳验算的构件其纵向受拉钢筋不得采用绑扎搭接接头也不宜采用焊接接头且严禁在钢筋上焊有任何附件端部锚固除外。
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
父母离异的话,会不会导致孩子心智不成熟? 过节 公司给我们发的购物卡 这个怎么做分录 属于福利费吗 需要计提吗... 乡村振兴公务员和省考公务员有什么区别 ...小时候跟着爷爷学国画书法,小受家是农村的,小受姓夏或叶,他带着他... 瑞麒X1安全装置 瑞麒X1的舒适型和豪华型有什么区别?配置有哪些不同的地方?这5000块多在... 瑞麒X1的安全性能方面配置如何? 脚崴了 有大量於血 怎么样才能快速消肿 脚崴了外侧出现瘀血浮肿怎么消除? ...换了我喜欢的发型,但是穿了件有点透明的衣服,可以看到肩_百度... 如何通过java代码生成word文档 请问对联上用的是什么字体 这对联上是什么字啊??完全看不懂 对联一般几个字,是上下联的,有字限吗 谁能认出对联上的字?谢谢!最好有出处 春联上的那些字是什么语? 这个对联上的字都念什么? 春节对联上有哪些字? 对联的字 羊毛衫缩水怎么样增大 初一上册数学整式加减、整式化简求值、有理数混合运算的计算题,越多越好,考烂了要用。。。 我儿子刚出院想问一下入太平人寿保险可以立刻成保吗?有没有过渡期 新生儿出生2个月后办理的医保,4个月生病时不能报销是为什么? 南京新生儿医保生完以后办理可以马上使用吗? 初一数学多项式题 新生儿购买2020年少儿互助金买了过后什么时间生效? 七年级较难的数学计算题带答案 新生儿住院跨年了 医保应该交前一年还是后一年的? 在中国如何办理 美国运通卡American Express 哪个银行可以办?工行吗? 手机屏幕贴膜知多少 哪种类型最适合你 手表摔了,后表壳脱了,指针不走,怎么办? 手表摔坏了 黑屏了怎么办? 手表摔了一下就不走了,而且不能调时间,怎么回事, 机械表摔了一下有木有事? 手表摔坏了 应聘书格式及范文是什么啊? 竞聘牛奶销售主管的履职规划怎么写 竞选销售主管演讲稿(2分钟左右) 快销品牛奶销售主管竞聘的岗位认知和履职规划 机械师t58-v在恢复出厂设置时不小心关机了导致卡在开机界面怎么办? 怎么给Win10系统增加空间内存 增加储存 硬盘如何重新分区? 想增加系统盘的空间 如何增加win10系统c盘空间 增加手机系统空间 如果25的钢筋必须搭结怎么接 物质能溶解在水中的特点有哪4种 物质有哪个特点能在水中溶解 物质在水中溶解的特征 小学三年级科学物质能在水中溶解的特点是_、_、_、_什么?希望朋友帮忙解答 什么叫物质能溶于水以及能溶于水的条件?