当前位置: 首页 > news >正文

网站备案名可以更改吗网页设计与制作基础知识总结

网站备案名可以更改吗,网页设计与制作基础知识总结,做网站不想用微软雅黑了,网页设计师的能力文章目录 properties文件连接池service层实现类dao层实现类dao层实现类 连接池类: 创建线程池静态常量#xff0c;用于放连接。 创建Properties静态常量#xff0c;用于解析properties文件 静态代码块中#xff0c;解析properties文件#xff0c;将解析结果用于创建连接池 … 文章目录 properties文件连接池service层实现类dao层实现类dao层实现类 连接池类: 创建线程池静态常量用于放连接。 创建Properties静态常量用于解析properties文件 静态代码块中解析properties文件将解析结果用于创建连接池 连接方法:用线程获取连接若没有从连接池中拿一个连接放到线程中去 释放连接方法:将线程变量清除去除事务连接放到连接池中 service层实现类 从连接池中获取一个连接这个连接是在线程中 设置事务(自动提交为false) 获取两个dao两个dao都是操作同一个连接 提交事务 释放连接 dao层减钱、加钱 properties文件 driverClasscom.mysql.cj.jdbc.Driver urljdbc:mysql://localhost:3306/test?rewriteBatchedStatementstrue usernameroot passwordroot initialSize10 maxActive20 minIdle5 maxWait5000连接池 package com.aistart.tech.utils;import com.alibaba.druid.pool.DruidDataSourceFactory;import javax.sql.DataSource; import java.io.IOException; import java.sql.*; import java.util.Properties;public class JdbcPoolUtil {private static ThreadLocalConnection threadLocal new ThreadLocal();private static final Properties info new Properties();private static DataSource dataSource null; // private static Connection connection null;static {try {info.load(JdbcPoolUtil.class.getClassLoader().getResourceAsStream(com/aistart/tech/config/druid.properties));} catch (IOException e) {throw new RuntimeException(e);}//数据库连接池应该也同时被创建try {dataSource DruidDataSourceFactory.createDataSource(info);} catch (Exception e) {throw new RuntimeException(e);}}public static Connection getConnection() throws SQLException {Connection connection threadLocal.get();if (connectionnull){connection dataSource.getConnection();threadLocal.set(connection);}return connection;}public static void freeConnection(){Connection connection threadLocal.get();if (connection!null){try {//把线程变量清除threadLocal.remove();//恢复原来的状态connection.setAutoCommit(true);connection.close();} catch (SQLException e) {throw new RuntimeException(e);}}}} service层实现类 package com.aistart.tech.servcice.impl;import com.aistart.tech.dao.IAccuntDao; import com.aistart.tech.dao.impl.AccuntDaoImpl; import com.aistart.tech.entity.Accunt; import com.aistart.tech.servcice.AccountService; import com.aistart.tech.utils.JdbcPoolUtil;import java.sql.Connection; import java.sql.SQLException;public class AccountServiceImpl implements AccountService {IAccuntDao accuntDao new AccuntDaoImpl();Overridepublic int getBalance(int id) {return 0;}Overridepublic boolean transferMoney(Accunt accunt1, Accunt accunt2,int money) {Connection connection null;try {//从数据库连接池拿出来一个连接connection JdbcPoolUtil.getConnection();connection.setAutoCommit(false);accuntDao.subMoney(accunt1.getId(),money);accuntDao.addMoney(accunt2.getId(),money);connection.commit();System.out.println(service的conn connection.getAutoCommit());} catch (Exception e) {try {connection.rollback();} catch (SQLException ex) {throw new RuntimeException(ex);}throw new RuntimeException(e);}finally {JdbcPoolUtil.freeConnection();}return false;} } dao层实现类 package com.aistart.tech.dao.impl;import com.aistart.tech.dao.IAccuntDao; import com.aistart.tech.utils.JdbcPoolUtil;import java.sql.Connection; import java.sql.SQLException;public class AccuntDaoImpl implements IAccuntDao {Overridepublic int subMoney(int id, int money) {Connection connection null;if (connection null) {try {connection JdbcPoolUtil.getConnection();System.out.println(这是dao层的connectionconnection.getAutoCommit());} catch (SQLException e) {throw new RuntimeException(e);}}return 0;}Overridepublic int addMoney(int id, int money) {return 0;} }dao层实现类 package com.aistart.tech.dao.impl;import com.aistart.tech.dao.IAccuntDao; import com.aistart.tech.utils.JdbcPoolUtil;import java.sql.Connection; import java.sql.SQLException;public class AccuntDaoImpl implements IAccuntDao {Overridepublic int subMoney(int id, int money) {Connection connection null;if (connection null) {try {connection JdbcPoolUtil.getConnection();System.out.println(这是dao层的connectionconnection.getAutoCommit());} catch (SQLException e) {throw new RuntimeException(e);}}return 0;}Overridepublic int addMoney(int id, int money) {return 0;} }
http://www.zqtcl.cn/news/821786/

相关文章:

  • 企业只有建立了自己的网站网站建设骗子
  • 凡科 360免费建站培训网页制作机构
  • 做网站用什么后缀好法人变更在哪个网站做公示
  • 公司建一个网站多少钱戴尔公司网站建设
  • 可以做试卷网站数学试卷小学六白沟网站开发
  • 宁波个人网站建设好看的网站在哪里好找
  • 宜春做网站公司wordpress 朋友圈插件
  • 做特价网站ckplayer wordpress
  • 网站运营需要服务器吗在哪个网站做图片视频带音乐
  • 大连网站备案高品质网站建设公司
  • 建站模板哪个好网站添加子域名
  • html5创意网站创建网站公司好
  • php网站开发外文旅游电子商务网站的品牌建设
  • 陕西西安网站建设公司哪家好网页框架是什么
  • 广东网站建设效果安福网站建设
  • 如何将html发布到网站微帮网免费发布信息网
  • 做个网站西安专业网络推广公司
  • 建设网站cms网站开发后台需要自己写吗
  • 天津协会网站建设学计算机的做网站的叫什么工作
  • 商城网站建设缺点淘宝店铺怎么免费推广
  • 利于优化的网站模板360建筑网密码忘了
  • 商务网站建设找哪家网页设计商品页面制作
  • 连云港网站建设方案大型门户网站多少钱
  • win7 iis设置网站首页网站建设攵金手指科杰壹陆
  • 阿里巴巴网站建设的功能定位手机在线制作图片加字
  • 网站联系我们的地图怎么做的电子商务网站建设完整案例教程
  • 北京学习网站建设湖北省建设厅政务公开网站
  • 推广做网站联系方式贵州省领导班子名单一览表
  • 厦门的网站建设公司徐州城乡建设局网站
  • 天津圣辉友联网站建设南昌本地生活网站有哪些