当前位置: 首页 > 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.pierceye.com/news/821786/

相关文章:

  • 买服务器做网站 镜像选什么网页设计用的软件
  • 内江 网站建设网站后台登录地址
  • 网站建设合同副本临沂建设局官方网站
  • 林州网站建设哪家好网站做电子链接标识申请好吗
  • 石家庄开发网站建设263企业邮箱登录邮箱
  • 青岛公司建设网站电子商务网站开发技术论文
  • 龙华网站的建设建设网站教程视频视频
  • 威海高区建设局网站品牌网站建设多少钱
  • 网站php网站空间新乡河南网站建设
  • 你第一个物流网站建设方案信诚网络公司网站
  • 企业建站什么网站好wordpress管理员后台
  • 南京网站开发价格两个wordpress共用一个数据库
  • 番禺制作网站平台柳城网站制作
  • 网站建设相关视频教程网页设计布局有哪几种方法
  • 能接做网站的活的网站上海建网站方案
  • 免费网站软件app大全飘雪影院手机免费观看免费
  • 怎么做类似淘宝的网站石家庄网络开发公司
  • 专业SEO教程网站广东省住房与城乡建设部网站
  • 360免费建站为什么注册不了雨灿网站建设
  • 益阳市建设局网站在家来料加工
  • 邵阳网站设计宠物网站 html模板
  • 网站域名以co与com有什么不同18款禁用黄a免费
  • 农村电商网站建设方案wordpress官网密码错误
  • 婚庆公司网站建设doc高端网站建设推广
  • 做房地产一级市场的看什么网站网站建建设公司和网络自建
  • 搞一个网站要多少钱长治做网站哪家好
  • 德州口碑好的网站制作公司网站运营托管咨询
  • 东阳网站建设价格广州最好的网站设计
  • 襄垣网站建设宝塔面板怎么搭建网站
  • 电影网站源码access广州网站建设排名一览表